Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -5011,6 +5011,18 @@ output$download_ui <- renderUI({
|
|
| 5011 |
downloadButton("download_all_coastal_advanced_pitchers", "Download All Advanced Pitcher Reports (ZIP)", class="btn-secondary")
|
| 5012 |
)
|
| 5013 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5014 |
} else if (input$report_type == "catcher") {
|
| 5015 |
df <- data_catcher(); if (is.null(df) || !"CatcherTeam" %in% names(df)) return(NULL)
|
| 5016 |
cts <- df %>% filter(CatcherTeam == "COA_CHA") %>% pull(Catcher) %>% unique() %>% na.omit()
|
|
@@ -5577,6 +5589,39 @@ output$preview_bp_zone <- renderPlot({
|
|
| 5577 |
},
|
| 5578 |
contentType = "application/zip"
|
| 5579 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 5580 |
|
| 5581 |
output$download_all_ccu_catchers <- downloadHandler(
|
| 5582 |
filename = function() {
|
|
|
|
| 5011 |
downloadButton("download_all_coastal_advanced_pitchers", "Download All Advanced Pitcher Reports (ZIP)", class="btn-secondary")
|
| 5012 |
)
|
| 5013 |
)
|
| 5014 |
+
} else if (input$report_type == "tableau_pitcher") {
|
| 5015 |
+
df <- data_pitcher(); if (is.null(df) || !"PitcherTeam" %in% names(df)) return(NULL)
|
| 5016 |
+
coastal_pitchers <- df %>% filter(PitcherTeam == "COA_CHA") %>% pull(Pitcher) %>% unique() %>% na.omit()
|
| 5017 |
+
if (!length(coastal_pitchers)) return(NULL)
|
| 5018 |
+
tagList(
|
| 5019 |
+
br(),
|
| 5020 |
+
div(style="text-align:center;padding:10px;background:#f0f8f8;border-radius:6px;margin-top:10px;",
|
| 5021 |
+
p(strong("Coastal Carolina Pitchers Found: ", length(coastal_pitchers)),
|
| 5022 |
+
style="color:#006F71;margin:5px 0;"),
|
| 5023 |
+
downloadButton("download_all_coastal_tableau_pitchers", "Download All Coastal Tableau Reports (ZIP)", class="btn-secondary")
|
| 5024 |
+
)
|
| 5025 |
+
)
|
| 5026 |
} else if (input$report_type == "catcher") {
|
| 5027 |
df <- data_catcher(); if (is.null(df) || !"CatcherTeam" %in% names(df)) return(NULL)
|
| 5028 |
cts <- df %>% filter(CatcherTeam == "COA_CHA") %>% pull(Catcher) %>% unique() %>% na.omit()
|
|
|
|
| 5589 |
},
|
| 5590 |
contentType = "application/zip"
|
| 5591 |
)
|
| 5592 |
+
|
| 5593 |
+
output$download_all_coastal_tableau_pitchers <- downloadHandler(
|
| 5594 |
+
filename = function() {
|
| 5595 |
+
df <- data_pitcher(); req(df)
|
| 5596 |
+
paste0("Coastal_Tableau_Pitcher_Reports_", format(parse_game_day(df), "%Y%m%d"), ".zip")
|
| 5597 |
+
},
|
| 5598 |
+
content = function(file) {
|
| 5599 |
+
df <- data_pitcher(); req(df)
|
| 5600 |
+
pitchers <- df %>% filter(PitcherTeam == "COA_CHA") %>% pull(Pitcher) %>% unique() %>% na.omit() %>% sort()
|
| 5601 |
+
if (!length(pitchers)) {
|
| 5602 |
+
showNotification("No Coastal pitchers found", type="error", duration=5)
|
| 5603 |
+
return(NULL)
|
| 5604 |
+
}
|
| 5605 |
+
withProgress(message='Generating Coastal Tableau Pitcher Reports', value=0, {
|
| 5606 |
+
tmp <- tempdir(); pdfs <- character(0); total <- length(pitchers)
|
| 5607 |
+
for (i in seq_along(pitchers)) {
|
| 5608 |
+
ply <- pitchers[i]; incProgress(1/total, detail=paste("Report for", ply))
|
| 5609 |
+
out <- file.path(tmp, paste0(gsub(" ","_",ply), "_",
|
| 5610 |
+
format(parse_game_day(df), "%Y%m%d"),
|
| 5611 |
+
"_Tableau_Report.pdf"))
|
| 5612 |
+
try(create_tableau_pitcher_pdf(df, ply, out), silent = TRUE)
|
| 5613 |
+
if (file.exists(out)) pdfs <- c(pdfs, out)
|
| 5614 |
+
}
|
| 5615 |
+
if (!length(pdfs)) {
|
| 5616 |
+
showNotification("Failed to generate reports", type="error", duration=5)
|
| 5617 |
+
return(NULL)
|
| 5618 |
+
}
|
| 5619 |
+
zip::zip(zipfile=file, files=basename(pdfs), root=tmp); unlink(pdfs)
|
| 5620 |
+
})
|
| 5621 |
+
showNotification("Coastal Tableau pitcher ZIP ready!", type="message", duration=5)
|
| 5622 |
+
},
|
| 5623 |
+
contentType = "application/zip"
|
| 5624 |
+
)
|
| 5625 |
|
| 5626 |
output$download_all_ccu_catchers <- downloadHandler(
|
| 5627 |
filename = function() {
|