From d5a5708b15a16d62a46383324f15d278320d9fb0 Mon Sep 17 00:00:00 2001 From: Eric Nantz Date: Thu, 11 Apr 2024 00:28:57 -0400 Subject: [PATCH] use new text file to obtain date of analysis --- R/utils.R | 15 +++++++++++++++ index.qmd | 12 +++++++----- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/R/utils.R b/R/utils.R index 53e489b..ce81e99 100644 --- a/R/utils.R +++ b/R/utils.R @@ -68,6 +68,21 @@ podcastdb_log_object <- function(root_url, date = format(Sys.time(), "%Y-%m-%d") return(res) } +podcastdb_timestamp_object <- function(url, dev_mode = FALSE) { + if (dev_mode) { + tmp_file <- "dev_files/job_timestamp.txt" + } else { + tmp_file <- tempfile(pattern = "job_timestamp") + + download.file( + url = url, + destfile = tmp_file + ) + } + res <- readLines(tmp_file) + return(res) +} + date_report <- function(log_object, tz = "UTC") { dt <- log_object |> filter(arg1 == "Downloading podcast database") |> diff --git a/index.qmd b/index.qmd index 011b92a..8204d54 100644 --- a/index.qmd +++ b/index.qmd @@ -21,6 +21,7 @@ params: pointblank_object_path: "https://podcast20-projects.us-east-1.linodeobjects.com/exports/podcastdb_pointblank_object/podcastdb_pointblank_object" podcast_dup_df_path: "https://podcast20-projects.us-east-1.linodeobjects.com/exports/podcast_dup_df.rds" podcast_analysis_df_path: "https://podcast20-projects.us-east-1.linodeobjects.com/exports/analysis_metrics_df.rds" + podcast_timestamp_path: "https://podcast20-projects.us-east-1.linodeobjects.com/exports/job_timestamp.txt" podcast_log_path: "https://podcast20-projects.us-east-1.linodeobjects.com/logs/" --- @@ -53,12 +54,13 @@ source("R/fct_tables.R") pointblank_object <- podcastdb_pointblank_object(url = params$pointblank_object_path, dev_mode = params$dev_mode) podcast_dup_df <- podcastdb_dupdf_object(url = params$podcast_dup_df_path, dev_mode = params$dev_mode) analysis_metrics_df <- podcastdb_analysisdf_object(url = params$podcast_analysis_df_path, dev_mode = params$dev_mode) +podcast_db_date <- podcastdb_timestamp_object(url = params$podcast_timestamp_path, dev_mode = params$dev_mode) -if (!params$dev_mode) { - podcast_db_date <- podcastdb_log_object(root_url = params$podcast_log_path, date = as.character(lubridate::today())) |> date_report() -} else { - podcast_db_date <- "20XX-XX-XX" -} +# if (!params$dev_mode) { +# podcast_db_date <- podcastdb_log_object(root_url = params$podcast_log_path, date = as.character(lubridate::today())) |> date_report() +# } else { +# podcast_db_date <- "20XX-XX-XX" +# } ```