Closed bbest closed 2 years ago
Working off apps_dev branch in /share/github/apps_dev
displayed in:
per:
ls -la /srv/shiny-server
report-v2-dev -> /share/github/apps_dev/report-v2
Purpose: configure the API request to generate the report.
Working off apps_dev branch in /share/github/apps_dev
displayed in:
per:
ls -la /srv/shiny-server
report-v2-dev -> /share/github/apps_dev/report-v2
ui.R: btn_rpt_create
:
https://github.com/marineenergy/apps/blob/51380df264f05d73a7a5b3acaf5f0b18a7d4a2b6/report-v2/ui.R#L273
server.R: input$btn_rpt_create
:
https://github.com/marineenergy/apps/blob/51380df264f05d73a7a5b3acaf5f0b18a7d4a2b6/report-v2/server.R#L717-L772
Submits to the api url_rpt_pfx
"https://api.marineenergy.app/report", which is the report endpoint of the https://api.marineenergy.app.
plumber_r <- "/share/github/api/plumber.R"
# TODO: reset default values to Null or blank
function(
req,
email = "bdbest@gmail.com",
date = "2021-05-25 19:11:49 UTC",
title = "Test Report",
filetype = "html",
contents = '{"Projects":[true],"Management":[true]}',
interactions = '[["Receptor.Fish","Stressor.PhysicalInteraction.Collision"],["Technology.Wave","Receptor.Birds"]]',
res) {
...
dir_rpt_pfx <- "/share/user_reports"
...
r_script <- "/share/github/api/scripts/render_yml.R"
...
# get hash for unique filename by digesting metadata
hsh <- digest::digest(m, algo="crc32")
yml <- glue::glue("{dir_rpt_pfx}/{email}/report_{hsh}.yml")
...
cmd <- glue::glue('r_script={r_script}\n yml={yml}\n log={log}\n $r_script $yml > $log 2>> $log')
...
system(cmd, wait = F)
setwd("/share/github/api")
template_rmd <- "/share/github/api/_report.Rmd"
source("/share/github/apps_dev/scripts/common.R")
source(file.path(dir_scripts, "report.R"))
...
# write Rmd of custom report
message("frontmatter for Rmd... ----")
message(yaml::as.yaml(fm))
...
message("rendering...")
rmarkdown::render(
input = rmd,
output_file = out)
Let's look at example reports in /share/user_reports/ben@ecoquants.com
that currently:
do render
Test w/ Cristina: marmam & noise | 2021-11-10 21:44:22 UTC | Published | Projects, Management | 1
report_81fb65d5.yml
:
email: ben@ecoquants.com
date: 2021-11-10 21:44:22 UTC
title: 'Test w/ Cristina: marmam & noise'
filetype: html
contents:
projects: yes
management: yes
interactions:
- - Receptor.MarineMammals
- Stressor.Noise
do NOT render
Testing w/ Tech Crew | 2021-11-09 21:57:56 UTC | Rendering... | Projects, Management | 0
report_b7388e28.yml
email: ben@ecoquants.com
date: 2021-11-09 21:57:56 UTC
title: Testing w/ Tech Crew
filetype: html
contents:
projects: yes
management: yes
interactions: []
The report API is only setup to write outputs per content type given a set of interactions (ie combinations of technology/stressor/receptor tags).
This is handled in render_yml.R#L64 with the rpt_content()
function:
r <- lapply(contents, rpt_content, ixns = p$interactions, rmd = rmd)
And this function is defined in:
So need to make another option, like in render_yml.R#L64:
if (length(p$interactions) == 0) {
# TODO: return table of all content
} else {
# carry on as originally designed
r <- lapply(contents, rpt_content, ixns = p$interactions, rmd = rmd)
}`
Here's the content that is queryable in the app and folded into the output custom report: