Skip to content

Commit 7f55fd9

Browse files
refactor: centralize logic for computing year/month/quarter formatting
1 parent 5ecf8bb commit 7f55fd9

1 file changed

Lines changed: 16 additions & 12 deletions

File tree

update_archives.R

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -4,19 +4,18 @@ library(xml2)
44
URL_BASE ='https://stat.ethz.ch/pipermail'
55
# POSIXlt facilitates formatting as quarter
66
today = as.POSIXlt(Sys.time())
7+
78
mailing_lists = list(
8-
c(name = 'r-devel', current = format(today, '%Y-%B.txt')),
9-
c(name = 'r-package-devel',
10-
current = with(today, sprintf('%dq%d.txt', year + 1900L, mon %/% 3L + 1L))),
11-
c(name = 'r-sig-mac', current = format(today, '%Y-%B.txt')),
12-
c(name = 'r-help', current = format(today, '%Y-%B.txt')),
13-
c(name = 'r-announce', current = format(today, '%Y')),
14-
c(name = 'r-sig-geo', current = format(today, '%Y-%B.txt')),
15-
c(name = 'r-sig-finance',
16-
current = with(today, sprintf('%dq%d.txt', year + 1900L, mon %/% 3L + 1L))),
17-
c(name = 'r-sig-mixed-models',
18-
current = with(today, sprintf('%dq%d.txt', year + 1900L, mon %/% 3L + 1L)))
9+
c(name = 'r-devel', frequency = 'month'),
10+
c(name = 'r-package-devel', frequency = 'quarter'),
11+
c(name = 'r-sig-mac', frequency = 'month'),
12+
c(name = 'r-help', frequency = 'month'),
13+
c(name = 'r-announce', frequency = 'annual'),
14+
c(name = 'r-sig-geo', frequency = 'month'),
15+
c(name = 'r-sig-finance', frequency = 'quarter'),
16+
c(name = 'r-sig-mixed-models', frequency = 'quarter')
1917
)
18+
2019
for (ii in seq_along(mailing_lists)) {
2120
this_list = mailing_lists[[ii]]
2221
outdir = this_list[['name']]
@@ -25,9 +24,14 @@ for (ii in seq_along(mailing_lists)) {
2524
dir.create(outdir, recursive = TRUE, showWarnings = FALSE)
2625

2726
# Always re-write current period
27+
current_period <- switch(this_list[['frequency']],
28+
annual = format(today, '%Y'),
29+
quarter = with(today, sprintf('%dq%d.txt', year + 1900L, mon %/% 3L + 1L)),
30+
month = format(today, '%Y-%B')
31+
)
2832
extant_gz = outdir |>
2933
list.files() |>
30-
setdiff(this_list[['current']]) |>
34+
setdiff(current_period) |>
3135
paste0('.gz')
3236

3337
zips = URL |>

0 commit comments

Comments
 (0)