Skip to content

Commit

Permalink
Fix display week calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
ibacher committed Jan 8, 2024
1 parent 859e15c commit ec07d76
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions docker-resources/plumber.R
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ function(
model_version = ml_model_version,
start_date = start_of_week,
end_date = end_of_week,
week = clock::date_format(clock::add_weeks(week_start(rtc_date), -1), format="%Y-W%U"),
week = get_week_number(rtc_date),
.keep = "unused"
)

Expand All @@ -163,7 +163,7 @@ function(
model_version = ml_model_version,
start_date = start_of_week,
end_date = end_of_week,
week = clock::date_format(clock::add_weeks(week_start(rtc_date), -1), format="%Y-W%U"),
week = get_week_number(rtc_date),
.keep = "unused"
)

Expand Down Expand Up @@ -195,6 +195,12 @@ week_end <- function(date) {
clock::date_ceiling(date, "week", origin = as.Date("1970-01-04"))
}

get_week_number <- function(date) {
previous_week <- clock::add_weeks(week_start(date), -1)
ywd <- clock::as_iso_year_week_day(previous_week)
paste0(clock::get_year(ywd), "-W", clock::get_week(ywd))
}

adult_risk_threshold_query <-
"select
'Medium Risk' as risk,
Expand Down

0 comments on commit ec07d76

Please sign in to comment.