Skip to content

Commit

Permalink
Refactor get_updated_ona_data
Browse files Browse the repository at this point in the history
  • Loading branch information
truenomad committed Feb 6, 2025
1 parent 0dbc5ba commit 6538ab6
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions R/get_ona.R
Original file line number Diff line number Diff line change
Expand Up @@ -885,21 +885,21 @@ get_updated_ona_data <- function(base_url = "https://api.whonghub.org",

df_new_tot_cols <- ncol(df_new)
df_new_tot_rows <- nrow(df_new)

} else {
df_new <- NULL
df_new <- data.frame()
df_new_tot_cols <- 0
df_new_tot_rows <- 0
}

# Construct the log message
log_message <- data.frame(
form_id = form_id,
update_date = Sys.Date(),
total_columns = df_new_tot_cols,
total_columns = length(union(colnames(df), colnames(df_new))),
total_rows = format(nrow(df) + df_new_tot_rows, big.mark = ","),
new_columns = df_new_tot_rows - ncol(df),
new_rows = format(df_new_tot_rows, big.mark = ",")
new_columns = length(setdiff(colnames(df_new), colnames(df))),
new_rows = if (
df_new_tot_rows == 0) "No new data" else format(
df_new_tot_rows, big.mark = ",")
)

logs[[form_id]] <- log_message |>
Expand Down

0 comments on commit 6538ab6

Please sign in to comment.