Skip to content
Snippets Groups Projects
Verified Commit 1c746902 authored by Ruben van Dijk's avatar Ruben van Dijk
Browse files

Working server. TODO: swimmerId.txt.

parent e75d3e2e
Branches
No related tags found
1 merge request!6Filter dates and removed old figures
......@@ -8,6 +8,7 @@ library(readr)
library(purrr)
library(RestRserve)
library(lubridate)
library(data.table)
dir.create("libdir")
foldername <- list.files("/tmp", pattern="Rtmp.*", full.names=TRUE)
plotToString <- function(plot) {
......@@ -19,7 +20,11 @@ plotToString <- function(plot) {
return(response)
}
doId <- function(id,dates_to_drop) {
doId <- function(input) {
id <- input$id
dates_to_drop <- input$dates_to_drop
if(is.null(dates_to_drop)) dates_to_drop <- ""
dates_to_drop <- paste0('{', dates_to_drop, '}')
response <- list()
appendGraph <- function(item) {
......@@ -148,7 +153,7 @@ doId <- function(id,dates_to_drop) {
tabel=zonder_split%>% count(distance, stroke)
tabel=tabel[tabel$n>1,]
tabel=tabel%>%count(distance)
AfstandGefilterd<-zonder_split[zonder_split$distance %in% tabel$distance, ]
lijnenplot_gesplitst <- ggplot(AfstandGefilterd,
......@@ -169,7 +174,7 @@ app$add_get(
path = "/",
FUN = function(.req, .res) {
dir.create(foldername[[1]])
response <- doId(.req$parameters_query$id,.req$parameters_query$ignore_dates)
response <- doId(.req$parameters_query)
response <- map(response, function(input) {
return(ggplotly(input))
})
......@@ -191,9 +196,10 @@ app$add_get(
})
app$add_static("/libdir", "libdir")
backend <- BackendRserve$new()
swimmerId <- tryCatch(
swimmerData <- tryCatch(
{
read_lines("swimmerId.txt")[1]
dframe <- read.table(file='swimmerId.txt',header=FALSE, sep='=',col.names=c('Key','Value'))
data.table(dframe,key='Key')
},
warning = function(cond) {
print("WARNING:")
......@@ -209,8 +215,8 @@ swimmerId <- tryCatch(
test
}
)
if (swimmerId != 0) {
doId(swimmerId)
if (swimmerData != 0) {
doId(swimmerData)
} else {
args <- commandArgs(trailingOnly = TRUE)
if (length(args) == 1 && args[1] == "test") quit(status = 0)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment