Max noticed a strange error with the following query:
Test case:
target_id = '63491'
start_date = '2024-07-01'
end_date = '2024-07-04'
Currently if there are no rows returned for a given rain period:
- It looks for zero rows
- Then if it's the month is the same as the current month it gives the error you received
- Otherwise, it says no data in the database
|
rain_temp <- DBI::dbGetQuery(con, rain_query) |
|
# Error messages if there are no rows in returned from the DB |
|
if(nrow(rain_temp) == 0){ |
|
|
|
if(lubridate::month(start_date) == lubridate::month(lubridate::today())){ |
|
stop(paste("Rainfall data appears in the MARS database on about a 5 week delay. \nData for", lubridate::month(start_date, label = TRUE, abbr = FALSE), "should be available in the second week of", lubridate::month(lubridate::today() + lubridate::dmonths(1), label = TRUE, abbr = FALSE))) |
|
} |
|
stop("There is no data in the database for this date range.") |
This should be changed to:
- If no data, return data frame with zero values for rain.
- We should make sure that all queries have zeros and not
NA since no rain is a known amount.
- Remove errors
Max noticed a strange error with the following query:
Currently if there are no rows returned for a given rain period:
pwdgsi/R/mars_data_fetch_write_functions.R
Lines 108 to 115 in f90bd1a
This should be changed to:
NAsince no rain is a known amount.