OwenStOnge commited on
Commit
b32800b
·
verified ·
1 Parent(s): 0b06cf7

Update app.R

Browse files
Files changed (1) hide show
  1. app.R +15 -14
app.R CHANGED
@@ -1808,24 +1808,25 @@ observeEvent(input$scrape_btn, {
1808
  gh_repo <- Sys.getenv("GITHUB_REPO")
1809
 
1810
  result <- tryCatch({
1811
- resp <- httr::POST(
1812
- paste0("https://huggingface.co/api/datasets/", repo_id, "/upload/main/", filename),
1813
  httr::add_headers(
1814
- Authorization = paste("Bearer", hf_token)
 
1815
  ),
1816
- body = list(file = httr::upload_file(tmp, type = "application/octet-stream")),
1817
- encode = "multipart"
 
 
 
 
 
 
 
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("Upload error:", e$message)
 
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()