-
Notifications
You must be signed in to change notification settings - Fork 0
/
plumber.R
executable file
·86 lines (75 loc) · 1.78 KB
/
plumber.R
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
#
# This is a Plumber API. You can run the API by clicking
# the 'Run API' button above.
#
# Find out more about building APIs with Plumber here:
#
# https://www.rplumber.io/
#
library(dplyr)
library(plumber)
library(reshape2)
library(janitor)
library(forecast)
# source('functions/forecast.R')
# source('functions/summary.R')
# source('functions/transform.R')
#* Log some information about the incoming request
#* @filter logger
function(req){
cat(as.character(Sys.time()), "-",
req$REQUEST_METHOD, req$PATH_INFO, "-",
req$HTTP_USER_AGENT, "@", req$REMOTE_ADDR, "\n")
plumber::forward()
}
#' @filter cors
cors <- function(res) {
res$setHeader("Access-Control-Allow-Origin", "*")
plumber::forward()
}
#* Echo back list with dataframes, filters and summary stats
#' @serializer unboxedJSON
#' @get /data
function(){
# data <- list(
# "MeanSumTotal" = MeanSumTotal,
# "MeanSumTotalWithAgent" = MeanSumTotalWithAgent,
# "MeanSumTotalMelted" = MeanSumTotalMelted
# )
#
# return(data)
list()
}
#* Echo back list with dataframes, filters and summary stats
#' @serializer unboxedJSON
#' @get /filters
function(){
# filters <- list(
# "businessUnits" = levels(as.factor(main$BUSINESS.UNIT)),
# "teams" = levels(main$TEAM),
# "agents" = levels(main$AGENT.NAME),
# "start" = levels(as.factor(main$MONTH)),
# "end" = levels(as.factor(main$MONTH)),
# "Ymetrics" = names(MeanSumTotal[-c(1,2,3,4)])
# )
# return(filters)
list()
}
# excel file
#' echo back the excel files
#' @get /excelfile
function() {
# start empty pivots list
pivots <- list()
# return
return(pivots)
}
#' echo back created forecasts
#' @get /forecasts
function() {
# return(createForecasts(main))
list()
}
# FRONT PAGE
#' @assets ./client/build /
list()