Skip to content

Commit

Permalink
updated db check to get latest date of data available
Browse files Browse the repository at this point in the history
  • Loading branch information
k-florek committed Jul 12, 2021
1 parent f93d793 commit 62aab7e
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion retrieve_data.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,23 @@ get_DHS_county_data <- function(){
"Washington","Waukesha","Waupaca","Waushara","Winnebago","Wood")

data = list()

# get last date of data
last_date = NA
c = 0
while(is.na(last_date)){
key = paste(Sys.Date()-c,"Dane",sep="_")
hit <- svc$query("DHS-SC2-County-Data",
KeyConditionExpression = "date_county = :value",
ExpressionAttributeValues = list(':value' = list('S' = key)))
if(hit$Count > 0){
last_date = Sys.Date()-c
}
c = c + 1
}

for(item in wi_counties){
key = paste(Sys.Date()-1,item,sep="_")
key = paste(last_date,item,sep="_")
hit <- svc$query("DHS-SC2-County-Data",
KeyConditionExpression = "date_county = :value",
ExpressionAttributeValues = list(':value' = list('S' = key))
Expand Down

0 comments on commit 62aab7e

Please sign in to comment.