Skip to content

Commit

Permalink
HaaS update
Browse files Browse the repository at this point in the history
  • Loading branch information
temospena committed Nov 23, 2023
1 parent 1244f45 commit e962d08
Showing 1 changed file with 34 additions and 3 deletions.
37 changes: 34 additions & 3 deletions HEAT/code/haas_reprex.R
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@


# read RDS exported from UI
webapp_input = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/1304_webapp_input.rds"))
genericdata = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/1304_generic_data_relevant_with_calc_params.rds"))
# read RDS exported from UI _OLD
# webapp_input = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/1304_webapp_input.rds"))
# genericdata = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/1304_generic_data_relevant_with_calc_params.rds"))


# read RDS exported from UI - NEW VERSION
webapp_input = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/2023_52_1304_webapp_input.rds"))
genericdata = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/2023_52_1304_generic_data_relevant_with_calc_params.rds"))


## 1. Input and returned data as json
Expand Down Expand Up @@ -117,6 +122,32 @@ from_rds_reprex <- unserialize(httr::content(resp_reprex, "raw"))



# REPREX ------------------------------------------------------------------

# read RDS exported from UI - NEW VERSION
webapp_input = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/2023_52_1304_webapp_input.rds"))
genericdata = readRDS(url("https://web.tecnico.ulisboa.pt/~rosamfelix/heat/2023_52_1304_generic_data_relevant_with_calc_params.rds"))

# to get data prepared by "calc_results"
# input data as "json", two inputs - "generic_data_relevant" from previous step
# returned data as "rds"
resp <-
httr::POST("https://api.heatwalkingcycling.org/apiv1/heat_5_0/calc_results?output_format=rds",
httr::set_cookies("user" = Sys.getenv("HEAT_COOKIE")),
body = jsonlite::toJSON(
list("webapp_input" = webapp_input,
"generic_data_relevant" = genericdata)),
encode = "multipart")

# convert to R
from_rds <- unserialize(httr::content(resp, "raw"))


# check the response
str(from_rds$results)

# Check final result value
from_rds$results$moneytotaldisc[36]-from_rds$results$moneytotaldisc[37]-from_rds$results$moneytotaldisc[38]+from_rds$results$moneytotaldisc[39]



Expand Down

0 comments on commit e962d08

Please sign in to comment.