Skip to content

Commit e15c3af

Browse files
committed
netlify formatting
1 parent ec30c2f commit e15c3af

File tree

2 files changed

+53
-22
lines changed

2 files changed

+53
-22
lines changed

R/utils.R

Lines changed: 46 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -366,26 +366,43 @@ update_site <- function() {
366366
slice_max(generation_date) %>%
367367
ungroup() %>%
368368
arrange(forecast_date)
369+
seasons <- tibble(
370+
season_name = c("2024-2025", "2025-2026"),
371+
season_start = as.Date(c("2024-11-20", "2025-06-04")),
372+
season_end = as.Date(c("2025-06-03", "2026-06-05"))
373+
)
374+
for (iSeason in 1:nrow(seasons)) {
375+
season_name <- seasons[[iSeason, "season_name"]]
376+
season_start <- seasons[[iSeason, "season_start"]]
377+
season_end <- seasons[[iSeason, "season_end"]]
378+
# Process each report file
379+
files_this_season <- used_reports %>%
380+
filter(season_start <= forecast_date, forecast_date < season_end) %>%
381+
pull(filename)
382+
for (report_file in files_this_season) {
383+
file_name <- path_file(report_file)
384+
file_parts <- str_split(fs::path_ext_remove(file_name), "_", simplify = TRUE)
385+
date <- file_parts[1]
386+
disease <- file_parts[2]
387+
generation_date <- file_parts[5]
388+
389+
report_link <- sprintf(
390+
"- [%s Forecasts %s, Rendered %s](%s)",
391+
str_to_title(disease),
392+
date,
393+
generation_date,
394+
file_name
395+
)
369396

370-
# Process each report file
371-
for (report_file in used_reports$filename) {
372-
file_name <- path_file(report_file)
373-
file_parts <- str_split(fs::path_ext_remove(file_name), "_", simplify = TRUE)
374-
date <- file_parts[1]
375-
disease <- file_parts[2]
376-
generation_date <- file_parts[5]
377-
378-
report_link <- sprintf(
379-
"- [%s Forecasts %s, Rendered %s](%s)",
380-
str_to_title(disease),
381-
date,
382-
generation_date,
383-
file_name
384-
)
385-
386-
# Insert into Production Reports section, skipping a line
387-
prod_reports_index <- which(grepl("## Weekly Fanplots 2024-2025 Season", report_md_content)) + 1
388-
report_md_content <- append(report_md_content, report_link, after = prod_reports_index)
397+
# Insert into Production Reports section, skipping a line
398+
prod_reports_index <- which(grepl(glue("## Weekly Fanplots {season_name} Season"), report_md_content)) + 1
399+
report_md_content <- append(report_md_content, report_link, after = prod_reports_index)
400+
# insert into This week if it's actually from within the past week
401+
if (as.Date(generation_date) > Sys.Date() - 7) {
402+
prod_reports_index <- which(grepl(glue("## Most recent week"), report_md_content)) + 1
403+
report_md_content <- append(report_md_content, report_link, after = prod_reports_index)
404+
}
405+
}
389406
}
390407
score_files <- dir_ls(reports_dir, regex = ".*_scoring.html")
391408
score_table <- tibble(
@@ -404,17 +421,25 @@ update_site <- function() {
404421
file_parts <- str_split(fs::path_ext_remove(file_name), "_", simplify = TRUE)
405422
generation_date <- file_parts[1]
406423
disease <- file_parts[2]
424+
dataset <- file_parts[3]
407425

408426
report_link <- sprintf(
409-
"- [%s Scores, rendered %s](%s)",
427+
"- [%s %s Scores, rendered %s](%s)",
410428
str_to_title(disease),
429+
str_to_title(dataset),
411430
generation_date,
412431
file_name
413432
)
414433

415434
# Insert into Production Reports section, skipping a line
416-
prod_reports_index <- which(grepl("## Current score notebooks", report_md_content)) + 1
435+
prod_reports_index <- which(grepl("## Score notebooks", report_md_content)) + 1
417436
report_md_content <- append(report_md_content, report_link, after = prod_reports_index)
437+
# insert into This week if it's actually from within the past week
438+
if (as.Date(generation_date) > Sys.Date() - 7) {
439+
browser()
440+
prod_reports_index <- which(grepl(glue("## Most recent week"), report_md_content)) + 1
441+
report_md_content <- append(report_md_content, report_link, after = prod_reports_index)
442+
}
418443
}
419444

420445
# Write the updated content to report.md

reports/template.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,13 @@
99
- The backtesting reports were pre-season tests of a variety of forecasters on the 2023-2024 season's data.
1010
- A description of the forecaster families explored is provided at the bottom of the page.
1111

12-
## Current score notebooks
12+
## Most recent week
13+
14+
15+
## Score notebooks
16+
17+
18+
## Weekly Fanplots 2025-2026 Season
1319

1420

1521
## Weekly Fanplots 2024-2025 Season

0 commit comments

Comments
 (0)