From 922423f100a3a45488bbf40f48609bb17d2c80ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Cl=C3=A9ment=20VIOLET?= <22980442+clementviolet@users.noreply.github.com> Date: Mon, 25 Feb 2019 10:41:16 -0500 Subject: [PATCH] Fix network_id mismatch In case of `network[["name"]] = Name_with_Some_Upper_Case`, the network was uploaded in DB like this `network[["name"]] <- tolower(network[["name"]])`. But when `POST_interaction()`tried to get FK for the network, it could not match because the ` network[["name"]]` inside the function still had upper case. --- R/POST_interaction.R | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/R/POST_interaction.R b/R/POST_interaction.R index 4ec15d2..60c646f 100644 --- a/R/POST_interaction.R +++ b/R/POST_interaction.R @@ -39,12 +39,14 @@ # Create and inject interactions table ## POST_interaction <- function(inter_df, inter, enviro = NA, attr = NULL, users, network){ - +# inter_df <- FW_name[[1]];interx <- inter[[1]];enviro<-NA;users <- users;network <- network[[1]];attr <- attr_inter # Put attribute in lowercase attr[["name"]] <- tolower(attr[["name"]]) if(attr[["unit"]] != "NA") attr[["unit"]] <- tolower(attr[["unit"]]) - + # Put network name in lowercase to match network[["name"]] already in DB + network[["name"]] <- tolower(network[["name"]]) + # Retrive foreign keys ## node_from & node_to inter_df[, "node_from"] <- NA @@ -61,9 +63,9 @@ POST_interaction <- function(inter_df, inter, enviro = NA, attr = NULL, users, n inter_df[, "attr_id"] <- GET_fkey("attribute", c("name", "unit"), c(tolower(attr[["name"]]), attr[["unit"]])) } - if (length(content(httr::GET(url = gsub(" ", "%20", paste0(server, mangal.env$base, "/environment?name=", enviro[["name"]], "&date=", enviro[["date"]], "&value=", enviro[["value"]])), config = mangal.env$headers))) != 0){ - inter_df[, "environment_id"] <- GET_fkey("environment", c("name", "date", "value"), c(enviro[["name"]], enviro[["date"]], enviro[["value"]])) - } + # if (length(content(httr::GET(url = gsub(" ", "%20", paste0(server, mangal.env$base, "/environment?name=", enviro[["name"]], "&date=", enviro[["date"]], "&value=", enviro[["value"]])), config = mangal.env$headers))) != 0){ + # inter_df[, "environment_id"] <- GET_fkey("environment", c("name", "date", "value"), c(enviro[["name"]], enviro[["date"]], enviro[["value"]])) + # } if (length(content(httr::GET(url = gsub(" ", "%20", paste0(server, mangal.env$base, "/network?name=", network[["name"]], "&date=", network[["date"]])), config = mangal.env$headers))) != 0){ inter_df[, "network_id"] <- GET_fkey("network", c("name", "date"), c(network[["name"]], network[["date"]]))