add error to metadata table

This commit is contained in:
Patrick Schratz 2024-07-25 00:04:28 +02:00
commit 687b2cea36
Signed by: pat-s
GPG key ID: 3C6318841EF78925

View file

@ -1,7 +1,7 @@
#' @importFrom DBI dbConnect dbDisconnect dbWriteTable dbGetQuery dbExecute
store_build_metadata <- function(
package_name, tag, platform,
error_occurred, error, force = FALSE) {
error_occurred, error, force = FALSE, error = NULL) {
con <- DBI::dbConnect(RPostgres::Postgres(),
dbname = "build_metadata", host = "postgres-arm-binaries-r.devxy.io",
port = 15432, user = "arm_binaries", password = Sys.getenv("PGPASS")
@ -18,7 +18,7 @@ store_build_metadata <- function(
} else if (nrow(existing_entries) >= 1 && force) {
cli::cli_alert_info("{.fun store_build_metadata}: Force overwriting build metadata for {.pkg {package_name}} {.field {tag}} because {.code force = TRUE} was set.")
dbExecute(con, sprintf("UPDATE single_builds SET build_timestamp = '%s', error_occurred = %s WHERE package_name = '%s' and tag = '%s'", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, package_name, tag))
dbExecute(con, sprintf("UPDATE single_builds SET build_timestamp = '%s', error_occurred = %s, error = '%s' WHERE package_name = '%s' and tag = '%s'", format(Sys.time(), "%Y-%m-%d %H:%M:%S"), error_occurred, error, package_name, tag))
} else if (nrow(existing_entries) == 0) {
cli::cli_alert("{.fun store_build_metadata}: Storing build metadata for {.pkg {package_name}} {.field {tag}}.")
# Create a data frame with the metadata
@ -27,6 +27,7 @@ store_build_metadata <- function(
tag = tag,
platform = platform,
error_occurred = error_occurred,
error = error,
build_timestamp = format(Sys.time(), "%Y-%m-%d %H:%M:%S"),
build_duration = NA
)