Skip to content

Commit 5df50c1

Browse files
author
kdaily
committed
abstract generate and store
1 parent d829655 commit 5df50c1

File tree

2 files changed

+20
-13
lines changed

2 files changed

+20
-13
lines changed

inst/lib.R

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -327,4 +327,21 @@ topNEntities <- function(queryData, allUsers, topN=20) {
327327
dplyr::top_n(topN, n) %>%
328328
dplyr::arrange(-n) %>%
329329
dplyr::select(n)
330-
}
330+
}
331+
332+
REPORT_TEMPLATES <- c("report"="../report.Rmd")
333+
334+
generateAndStore <- function(myParams, reportType) {
335+
htmlFileName <- paste0(myParams[['projectId']], "_", reportType, "_",
336+
lubridate::today(), ".html")
337+
338+
outputFileName <- paste0(tempdir(), "/", htmlFileName)
339+
340+
rmarkdown::render(input=REPORT_TEMPLATES[[reportType]],
341+
output_file=outputFileName,
342+
params=myParams)
343+
344+
synStore(File(outputFileName,
345+
name="Usage Statistics",
346+
parentId=parentId))
347+
}

inst/scripts/manual_PCBC.R

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
library(synapseClient)
22
synapseLogin()
3+
source("../lib.R")
34

4-
templates <- c("report"="../report.Rmd")
55
reportType <- "report"
6-
76
projectId <- 'syn1773109'
87
parentId <- 'syn4892835'
98

@@ -12,13 +11,4 @@ myParams <- list(projectId=projectId,
1211
aclTeamOrder=c(2224090, 3319054, 273957, projectId),
1312
useTeamGrouping=FALSE)
1413

15-
htmlFileName <- paste0(myParams[['projectId']], "_", reportType, "_",
16-
lubridate::today(), ".html")
17-
18-
rmarkdown::render(input=templates[[reportType]],
19-
output_file=htmlFileName,
20-
params = myParams)
21-
22-
htmlFile <- synStore(File(paste0("../", htmlFileName),
23-
name="Usage Statistics",
24-
parentId=parentId))
14+
generateAndStore(myParams, reportType)

0 commit comments

Comments
 (0)