I am attempting to automatically update a data frame in a Shiny Application that scrapes JIRA's rest API to populate visuals.
I am borrowing from what I found here but the DB vs. Web Scrape doesn't seem to have a universal solution.
I am trying to globally define defects data (and update globally every 6 minutes) but when I attempt to filter the global data frame I get the Error in eval: object 'defects' not found error. Here is the Global Function I use to gather Updates
Getupdates <- function(qfrequency){
if(!exists("nextCall")){
lastcall <<- Sys.time()
message("Initiating")
baseURL <<- "https://oneit.wba.com/jira/rest/api/2/search?fields=created,resolutiondate,customfield_13601,customfield_11014,creator,assignee,reporter,customfield_13400,customfield_11014,customfield_12501,key,status&jql=project%20in%20(RXQE)%20AND%20issuetype%20=%20Bug%20AND%20%22Business%20Priority%22%20!=%20EMPTY%20AND%20status%20!=%20Removed&maxResults=500"
maxResults = 500
resultIndex <<- -1;
totalRecords <<- 0
pages <- list()
i<<-1
while(resultIndex < totalRecords){
url <<- paste0(baseURL, "&startAt=",resultIndex,"&maxResults=",maxResults) #CaPs MaTtER!
rawExport <<- fromJSON(url, flatten=TRUE)
resultIndex <<- rawExport$startAt + nrow(rawExport$issues)
totalRecords <<- rawExport$total
pages[[i]] <<- rawExport$issues
i<<-i+1
}
defects <- rbind_pages(pages)
nextCall <<- Sys.time() + qfrequency
message("Got Initial Data")
}
else if (Sys.time() >= nextCall){
lastcall <<- Sys.time()
message(paste0(Sys.time(), " Querying Periodically"))
baseURL <<- "https://oneit.wba.com/jira/rest/api/2/search?fields=created,resolutiondate,customfield_13601,customfield_11014,creator,assignee,reporter,customfield_13400,customfield_11014,customfield_12501,key,status&jql=project%20in%20(RXQE)%20AND%20issuetype%20=%20Bug%20AND%20%22Business%20Priority%22%20!=%20EMPTY%20AND%20status%20!=%20Removed&maxResults=500"
maxResults = 500
resultIndex <<- -1;
totalRecords <<- 0
pages <- list()
i<<-1
while(resultIndex < totalRecords){
url <<- paste0(baseURL, "&startAt=",resultIndex,"&maxResults=",maxResults) #CaPs MaTtER!
rawExport <<- fromJSON(url, flatten=TRUE)
resultIndex <<- rawExport$startAt + nrow(rawExport$issues)
totalRecords <<- rawExport$total
pages[[i]] <<- rawExport$issues
i<<-i+1
}
defects <- rbind_pages(pages)
nextCall <<- Sys.time() + qfrequency
message("Got Updated Data")
}
else{
return()
}
}
And the Beginning of the server code where I believe the error is origniating
server <- function(input, output, session) {
observe({
autoInvalidate()
# 300 seconds is 5 minute updates
Getupdates(UpdateR8)
})
Quality <- reactive({
rawNames <- c("fields.created", "fields.resolutiondate", "fields.customfield_13601.value",
"fields.creator.displayName", "fields.assignee.displayName",
"fields.customfield_13400.value","fields.customfield_11014.value",
"fields.customfield_12501.value",
"key", "fields.status.name", "fields.reporter.displayName")
myBugs <- defects %>% dplyr::select(rawNames) })
Any help on this would be wonderful!