-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fixes #15 - provide default sort order if not supplied in URL #109
Conversation
if (!is.null(names(parsedUrl$query))) # check if URL has any queries | ||
if(sum(sapply(names(parsedUrl$query), orderTest)) == 0) # check if URL is sorted | ||
# sort by Socrata unique identifier | ||
validUrl <- paste(validUrl, if(is.null(parsedUrl$query)) {'?'} else {"&"}, '$order=:id', sep='') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like the readability here.
Although, as I'm saying that, can I suggest this for the previous lines?
if (!is.null(names(parsedUrl$query))) # check if URL has any queries
## if there is a query, check for $order within the query
orderTest <- any(names(parsedUrl$query == "$order"))
if(orderTest)
...
Although I love the trick of summing logicals to mean "or", I'm pretty sure that will work without sapply
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tried substituting that code, but it broke a bunch of tests. I do like that its simpler and easier to read. I'll can try to tweak it and get it to work, since it looks like it should.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Got it to work and committed it. Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we need to include some tests to make sure this continues as expected in the future:
- Ensuring that the
$order=:id
is inserted when no other query parameters are used. - Ensuring that
$order=:id
is not used when other$order
parameters are requested by the user. - Ensuring that
$order=:id
is inserted when other (non-$order
) arguments are used.
I added some tests to ensure the expected behavior. I ended up having to add some code because I realized it wasn't adding Please note that these tests ensure that the data frame contents are what we would expect if the URL is properly constructed. But they do not actually test against the URL itself, since that is only known to the function and not available to the tests scripts. |
I never knew about that From: Nick Lucius [mailto:notifications@github.com] I added some tests to ensure the expected behavior. I ended up having to add some code because I realized it wasn't adding $order=:id to clean URLs with no query parameters. Please note that these tests ensure that the data frame contents are what we would expect if the URL is properly constructed. But they do not actually test against the URL itself, since that is only known to the function and not available to the tests scripts. — This e-mail, and any attachments thereto, is intended only for use by the addressee(s) named herein and may contain legally privileged and/or confidential information. If you are not the intended recipient of this e-mail (or the person responsible for delivering this document to the intended recipient), you are hereby notified that any dissemination, distribution, printing or copying of this e-mail, and any attachment thereto, is strictly prohibited. If you have received this e-mail in error, please respond to the individual sending the message, and permanently delete the original and any copy of any e-mail and printout thereof. |
Great! Resolved all of my comments. @geneorama - anything else that should be considered before merging? |
If the user does not include an
$order=
in the URL, this will insert$order=:id
.There are no tests provided because this issue should only occur when the a dataset is being changed at the same time
read.socrata()
is paging.fixes #15