Spaces:
Running
Running
Update app.R
Browse files
app.R
CHANGED
|
@@ -1808,24 +1808,25 @@ observeEvent(input$scrape_btn, {
|
|
| 1808 |
gh_repo <- Sys.getenv("GITHUB_REPO")
|
| 1809 |
|
| 1810 |
result <- tryCatch({
|
| 1811 |
-
|
| 1812 |
-
paste0("https://
|
| 1813 |
httr::add_headers(
|
| 1814 |
-
Authorization = paste("Bearer",
|
|
|
|
| 1815 |
),
|
| 1816 |
-
body =
|
| 1817 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1818 |
)
|
| 1819 |
-
|
| 1820 |
-
resp_text <- httr::content(resp, as = "text", encoding = "UTF-8")
|
| 1821 |
-
|
| 1822 |
-
if (httr::status_code(resp) %in% c(200, 201)) {
|
| 1823 |
-
paste0("Done! ", nrow(combined), " total rows in dataset.")
|
| 1824 |
-
} else {
|
| 1825 |
-
paste0("Upload failed: ", httr::status_code(resp), " - ", resp_text)
|
| 1826 |
-
}
|
| 1827 |
}, error = function(e) {
|
| 1828 |
-
paste("
|
|
|
|
| 1829 |
})
|
| 1830 |
|
| 1831 |
if (is.null(result)) return()
|
|
|
|
| 1808 |
gh_repo <- Sys.getenv("GITHUB_REPO")
|
| 1809 |
|
| 1810 |
result <- tryCatch({
|
| 1811 |
+
httr::POST(
|
| 1812 |
+
paste0("https://api.github.com/repos/", gh_repo, "/actions/workflows/scrape.yml/dispatches"),
|
| 1813 |
httr::add_headers(
|
| 1814 |
+
Authorization = paste("Bearer", gh_token),
|
| 1815 |
+
Accept = "application/vnd.github.v3+json"
|
| 1816 |
),
|
| 1817 |
+
body = jsonlite::toJSON(list(
|
| 1818 |
+
ref = "main",
|
| 1819 |
+
inputs = list(
|
| 1820 |
+
start_date = as.character(input$start_date),
|
| 1821 |
+
end_date = as.character(input$end_date),
|
| 1822 |
+
data_type = input$scrape_source
|
| 1823 |
+
)
|
| 1824 |
+
), auto_unbox = TRUE),
|
| 1825 |
+
encode = "raw"
|
| 1826 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1827 |
}, error = function(e) {
|
| 1828 |
+
scrape_status_msg(paste("Failed:", e$message))
|
| 1829 |
+
return(NULL)
|
| 1830 |
})
|
| 1831 |
|
| 1832 |
if (is.null(result)) return()
|