Skip to content

Commit

Permalink
fix: 🐛 with multiple upcoming courses this failed, fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
lwjohnst86 committed Dec 4, 2024
1 parent ccbc317 commit 431dc6f
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions R/course-metadata.R
Original file line number Diff line number Diff line change
Expand Up @@ -107,16 +107,23 @@ get_upcoming_course <- function() {
purrr::map("events") |>
purrr::map_depth(2, "date", .ragged = TRUE) |>
purrr::map(unlist) |>
purrr::map_lgl(\(x) {
purrr::map_chr(\(x) {
x <- x[x >= lubridate::today()]
if (!length(x)) {
x <- NA
# When no date exists, set to NA
NA
} else {
# Get the nearest date from future dates
min(x)
}
!is.na(min(x))
})
}) |>
lubridate::as_date()

course_id <- NA
if (all(upcoming)) {
# If there are any upcoming dates
if (any(!is.na(upcoming))) {
# The date should be the soonest of the upcoming dates
upcoming <- upcoming == min(upcoming, na.rm = TRUE)
course_id <- read_course_metadata() |>
purrr::map("id") |>
purrr::keep(upcoming) |>
Expand Down

0 comments on commit 431dc6f

Please sign in to comment.