Skip to content

Commit

Permalink
Fix network_id mismatch
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
clementviolet authored Feb 25, 2019
1 parent 85a0020 commit 922423f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions R/POST_interaction.R
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]]))
Expand Down

0 comments on commit 922423f

Please sign in to comment.