-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathsrvScheduler.R
96 lines (92 loc) · 3.52 KB
/
srvScheduler.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
87
88
89
90
91
92
93
94
95
96
# functions for setting up recurring tasks
# last update:2016-10-13
readSchedulerItems <- reactive({
app <- currApp()
if(length(app) > 0){
url <- itemsUrl(app[['url']], schedulerKey)
allItems <- readItems(app, url)
if(nrow(allItems) == 0){
data.frame()
} else {
allItems[allItems$app == app[['app_key']] &
!is.na(allItems$app), ]
}
} else {
data.frame()
}
})
readSchedulerItemsFunction <- function(){
app <- currApp()
if(length(app) > 0){
url <- itemsUrl(app[['url']], schedulerKey)
allItems <- readItems(app, url)
if(nrow(allItems) == 0){
data.frame()
} else {
allItems[allItems$app == app[['app_key']] &
!is.na(allItems$app), ]
}
} else {
data.frame()
}
}
writeSchedulerRscript <- function(app, app_name, rScript, time, repo, active, id){
rScript_fields <- list(
timestamp='Timestamp',
value='Rscript.result'
)
rScript_structure <- list(
repo=repo,
repoName=app_name,
fields=rScript_fields
)
response_structure <- list(
rScript_structure
)
parameters <- list(Rscript_base64 = base64Encode(rScript),
response_structure = response_structure,
pia_url = app[['url']],
app_key = app[['app_key']],
app_secret = app[['app_secret']])
config <- list(app = app[['app_key']],
time = time,
task = 'Rscript',
active = active,
parameters = parameters,
'_oydRepoName' = 'Scheduler')
if(missing(id)) {
writeItem(app,
itemsUrl(app[['url']], schedulerKey),
config)
} else {
updateItem(app,
itemsUrl(app[['url']], schedulerKey),
config,
id)
}
}
writeSchedulerRscriptReference <- function(app, app_name, scriptReference, time, replace, id){
replace$pia_url = app[['url']]
replace$app_key = app[['app_key']]
replace$app_secret = app[['app_secret']]
parameters <- list(Rscript_reference = scriptReference,
Rscript_repo = scriptRepo,
replace = replace)
config <- list(app = app[['app_key']],
name = app_name,
time = time,
task = 'Rscript',
active = TRUE,
parameters = parameters,
'_oydRepoName' = 'Scheduler')
if(missing(id)) {
writeItem(app,
itemsUrl(app[['url']], schedulerKey),
config)
} else {
updateItem(app,
itemsUrl(app[['url']], schedulerKey),
config,
id)
}
}