Skip to content

Commit 683e1cc

Browse files
committed
this fixes metadata methods so that Chicago#64 (comment) rowline is now splitted.
update description file & squash all the commits
1 parent d355b90 commit 683e1cc

File tree

14 files changed

+77
-36
lines changed

14 files changed

+77
-36
lines changed

.travis.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,18 @@ language: R
88
warnings_are_errors: true
99

1010
before_install:
11+
- sudo apt-get update -qq
1112
- sudo apt-get install libv8-dev
12-
13-
r_binary_packages:
14-
- rgdal
13+
- sudo add-apt-repository -y ppa:marutter/c2d4u
14+
- sudo apt-get update -qq
15+
16+
apt_packages:
17+
- libgdal-dev
18+
- libproj-dev
19+
- libhdf5-serial-dev
20+
21+
r_packages:
22+
- rgdal
1523

1624
r_github_packages:
1725
- hadley/httr

DESCRIPTION

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,18 @@ Version: 1.7.0-9
1313
Date: 2015-10-26
1414
Author: Hugh Devlin, Ph. D., Tom Schenk, Jr. and John Malc (@dmpe)
1515
Maintainer: "Tom Schenk Jr." <[email protected]>
16-
Depends:
16+
Depends:
1717
R (>= 3.2.2)
18-
Imports:
18+
Imports:
1919
httr (>= 1.0.0),
20-
jsonlite (>= 0.9.17),
21-
mime (>= 0.4),
22-
geojsonio (>= 0.1.4),
20+
jsonlite (>= 0.9.19),
21+
mime (>= 0.4),
22+
geojsonio (>= 0.1.4),
2323
plyr (>= 1.8.3)
24-
Suggests:
25-
testthat (>= 0.10.0),
26-
roxygen2 (>= 4.1.1),
24+
Suggests:
25+
testthat (>= 0.11.0),
26+
roxygen2 (>= 5.0.1),
2727
License: MIT + file LICENSE
2828
URL: https://github.com/Chicago/RSocrata
29-
BugReports: https://github.com/Chicago/RSocrata/issues
29+
BugReports: https://github.com/Chicago/RSocrata/issues
30+
RoxygenNote: 5.0.1

NAMESPACE

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Generated by roxygen2 (4.1.1): do not edit by hand
1+
# Generated by roxygen2: do not edit by hand
22

33
export(getMetadata)
44
export(isFourByFour)
@@ -10,9 +10,11 @@ importFrom(geojsonio,geojson_read)
1010
importFrom(httr,GET)
1111
importFrom(httr,add_headers)
1212
importFrom(httr,build_url)
13+
importFrom(httr,config)
1314
importFrom(httr,content)
1415
importFrom(httr,parse_url)
1516
importFrom(httr,stop_for_status)
17+
importFrom(httr,verbose)
1618
importFrom(jsonlite,fromJSON)
1719
importFrom(mime,guess_type)
1820
importFrom(plyr,rbind.fill)

R/errorHandling.R

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@
77
# See \url{https://github.com/Chicago/RSocrata/issues/16}
88
#
99
# @param url - SOPA url
10-
#' @importFrom httr stop_for_status GET add_headers
10+
#' @importFrom httr stop_for_status GET add_headers verbose config
1111
errorHandling <- function(url = "", app_token = NULL) {
12-
rsp <- httr::GET(url, httr::add_headers("X-App-Token" = app_token))
12+
rsp <- httr::GET(url, httr::add_headers("X-App-Token" = app_token), config(fresh_connect = 1L))
1313

1414
if (rsp$status_code == 200) {
1515
invisible("OK. Your request was successful.")

R/metadata.R

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,9 @@
2727
getMetadata <- function(url = "") {
2828

2929
urlParsedBase <- httr::parse_url(url)
30-
mimeType <- mime::guess_type(urlParsedBase$path)
31-
30+
3231
# use function below to get them using =COUNT(*) SODA query
33-
gQRC <- getQueryRowCount(urlParsedBase, mimeType)
32+
gQRC <- getQueryRowCount(urlParsedBase)
3433

3534
# create URL for metadata data frame
3635
fourByFour <- substr(basename(urlParsedBase$path), 1, 9)
@@ -48,7 +47,7 @@ getMetadata <- function(url = "") {
4847
suppressWarnings(max(df$cachedContents$non_null + df$cachedContents$null))
4948
} else {
5049
# as.numeric(ifelse(is.null(gQRC$count), gQRC$COUNT, gQRC$count)) # the reason
51-
as.numeric(tolower(gQRC$COUNT))
50+
as.numeric(getQueryRowCount(gQRC))
5251
}
5352

5453
columns <- as.numeric(nrow(df))
@@ -62,7 +61,11 @@ getMetadata <- function(url = "") {
6261
# @author Gene Leynes \email{gleynes@@gmail.com}
6362
#
6463
#' @importFrom httr GET build_url content
65-
getQueryRowCount <- function(urlParsed, mimeType) {
64+
getQueryRowCount <- function(validUrl) {
65+
66+
urlParsed <- httr::parse_url(validUrl)
67+
mimeType <- mime::guess_type(urlParsed$path)
68+
6669
## Construct the count query based on the URL,
6770
if (is.null(urlParsed[['query']])) {
6871
## If there is no query at all, create a simple count
@@ -93,5 +96,5 @@ getQueryRowCount <- function(urlParsed, mimeType) {
9396
## Limit the row count to $limit (if the $limit existed).
9497
# totalRows <- min(totalRows, as.numeric(rowLimit))
9598

96-
return(totalRows)
99+
return(totalRows[[1]])
97100
}

R/returnData.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ read.socrata <- function(url = NULL, app_token = NULL, limit = 50000, domain = N
111111
results <- getContentAsDataFrame(response)
112112
dataTypes <- getSodaTypes(response)
113113

114-
rowCount <- as.numeric(getMetadata(cleanQuest(validUrl))[1])
114+
rowCount <- as.numeric(getQueryRowCount(validUrl))
115115

116116
## More to come? Loop over pages implicitly
117117
while (nrow(results) < rowCount) {

man/getMetadata.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/isFourByFour.Rd

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/ls.socrata.Rd

Lines changed: 2 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/read.socrata.Rd

Lines changed: 9 additions & 7 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)