Skip to content

Commit a28e025

Browse files
committed
Address review comments
1 parent cbe3345 commit a28e025

File tree

4 files changed

+9
-7
lines changed

4 files changed

+9
-7
lines changed

R-packages/covidcast/R/covidcast.R

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -725,16 +725,18 @@ covidcast <- function(data_source, signal, time_type, geo_type, time_values,
725725
params$lag <- lag
726726
}
727727

728-
# Make the API call
729-
res <- .request(params)
730-
if (nchar(res) == 0) {
728+
# Make the API call. If the API returns a non-200 status code, indicating e.g.
729+
# a database error, .request() raises an error. It returns an empty string if
730+
# there are no results for our query.
731+
response <- .request(params)
732+
if (nchar(response) == 0) {
731733
# empty if no results
732734
return(NULL)
733735
}
734736

735737
# geo_value must be read as character so FIPS codes are returned as character,
736738
# not numbers (with leading 0s potentially removed)
737-
return(read.csv(textConnection(res), stringsAsFactors = FALSE,
739+
return(read.csv(textConnection(response), stringsAsFactors = FALSE,
738740
colClasses = c("geo_value" = "character")))
739741
}
740742

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
geo_value,signal,time_value,direction,issue,lag,value,stderr,sample_size
22
01001,bar,20200110,,20200111,1,91.2,0.8,114.2
3-
01002,bar,20200110,,20200111,1,99.1,0.2,217.8
3+
01002,bar,20200110,,20200111,1,99.1,0.2,217.8
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
geo_value,signal,time_value,direction,issue,lag,value,stderr,sample_size
22
31001,bar,20200112,,20200113,1,81.2,0.8,314.2
3-
31002,bar,20200112,,20200113,1,89.1,0.2,417.8
3+
31002,bar,20200112,,20200113,1,89.1,0.2,417.8

R-packages/covidcast/tests/testthat/test-covidcast.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ with_mock_api({
167167
})
168168

169169
test_that("covidcast_signal stops when end_day < start_day", {
170-
# reusing api.php-d2e163.json for metadata
170+
# reusing api.php-dd024f.csv for metadata
171171
expect_error(covidcast_signal("foo", "bar", "2020-01-02", "2020-01-01"))
172172
})
173173

0 commit comments

Comments
 (0)