Skip to content
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

Merged
merged 3 commits into from
Oct 26, 2016

Conversation

nicklucius
Copy link
Contributor

@nicklucius nicklucius commented Oct 12, 2016

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

@coveralls
Copy link

coveralls commented Oct 12, 2016

Coverage Status

Coverage decreased (-0.7%) to 96.241% when pulling 4076f00 on issue15 into d6e307f on dev.

@tomschenkjr tomschenkjr added this to the v1.7.1 milestone Oct 13, 2016
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='')
Copy link
Member

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.

Copy link
Contributor Author

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.

Copy link
Contributor Author

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!

Copy link
Contributor

@tomschenkjr tomschenkjr left a 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.

@nicklucius
Copy link
Contributor Author

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.

@tomschenkjr
Copy link
Contributor

I never knew about that info option in test_that(). Great way to document!

From: Nick Lucius [mailto:notifications@github.com]
Sent: Wednesday, October 19, 2016 9:44 AM
To: Chicago/RSocrata RSocrata@noreply.github.com
Cc: Schenk, Tom Tom.Schenk@cityofchicago.org; Comment comment@noreply.github.com
Subject: Re: [Chicago/RSocrata] fixes #15 - provide default sort order if not supplied in URL (#109)

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.


You are receiving this because you commented.
Reply to this email directly, view it on GitHubhttps://github.com//pull/109#issuecomment-254834608, or mute the threadhttps://github.com/notifications/unsubscribe-auth/ABkC0eGeNm436HIHxghcFkqubI3p3v_gks5q1izGgaJpZM4KVHHi.


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.

@tomschenkjr
Copy link
Contributor

Great! Resolved all of my comments. @geneorama - anything else that should be considered before merging?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants