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

Fix handling of fq #36

Merged
merged 4 commits into from Jan 7, 2020
Merged

Fix handling of fq #36

merged 4 commits into from Jan 7, 2020

Conversation

adam3smith
Copy link
Contributor

@adam3smith adam3smith commented Dec 21, 2019

Currently fq is completely broken:

  1. It requires start to be set for no reason
  2. It fails because match.arg will always fail since no args are given in the function

This fix does three things:

  1. Test for fq rather than start
  2. get rid of the match.arg -- since fq is super flexible, we can't use that here
  3. enclose the fq query in I to prevent URL encoding (see Encoding special characters using 'query' r-lib/httr#540 (comment) ). Otherwise, httr encodes colons, square brackets and + and e.g. the example for date range search breaks

Please ensure the following before submitting a PR:

  • if suggesting code changes or improvements, open an issue first
  • for all but trivial changes (e.g., typo fixes), add your name to DESCRIPTION
  • for all but trivial changes (e.g., typo fixes), documentation your change in NEWS.md with a parenthetical reference to the issue number being addressed
  • if changing documentation, edit files in /R not /man and run devtools::document() to update documentation
  • add code or new test files to /tests for any new functionality or bug fix
  • make sure R CMD check runs without error before submitting the PR

Currently fq is completely broken:
1. It requires start to be set for no reason
2. It fails because match.arg will always fail since no args are given in the function

This fix does three things:
1. Test for fq rather than start
2. get rid of the match.arg -- since fq is super flexible, we can't use that here
3. enclose the fq query in I to prevent URL encoding (see r-lib/httr#540 (comment) ). Otherwise, httr encodes colons, square brackets and + and e.g. the [example for date range search](http://guides.dataverse.org/en/latest/api/search.html#date-range-search-example) breaks
@adam3smith adam3smith mentioned this pull request Dec 21, 2019
3 tasks
@adam3smith
Copy link
Contributor Author

@wibeasley let me know if you need anything else on this (no particular rush on my end, but FWIW, I've been running this successfully from my fork)

@wibeasley
Copy link
Contributor

wibeasley commented Jan 6, 2020

thanks @adam3smith for the nudge.I like your fix and love that you included a test. Do you mind adding a few more tests, such as

  • 3+ different search terms (by themselves)
  • an fq that returns zero hits

- [ ] 3+ different search terms (in one url request)

I was planning to add them, but think you're a better fit. I've never used this parameter --and didn't even know what it was when I read your PR.

I am anxious to incorporate your PR and other son, before changes to the master require the PRs to merge the master's changes into the branches before they can be merged back into the master.

@adam3smith
Copy link
Contributor Author

Will do -- might take me a couple of days, but shouldn't be a problem.

@adam3smith
Copy link
Contributor Author

@wibeasley working on this -- I've added the zero hits test but I'm actually not quite clear what you're referring to with the two 3+ queries.
Am I understanding correctly that those test are general search tests, unrelated to fq? By "in one url request" you just mean a single search for author: King, type: dataset, title: replication ?
Not sure what you mean by "by themselves".

(Note that the dataverse API actually allows for multiple fq parameters in a single query, but the package (or maybe even R?) balks at having a parameter repeated. iIf that's OK I'd like to not address that for now since it may require more substantial code changes)

@wibeasley
Copy link
Contributor

wibeasley commented Jan 7, 2020

@adam3smith, (I'm looking at Advanced Search Example docs now. I've never used this, so feel free to tell me that I not making sense.)

Not sure what you mean by "by themselves".

maybe:

  1. fq = dateSort (which is already in your PR)
  2. fq = publicationDate
  3. fq = description?

Note that the Dataverse API actually allows for multiple fq parameters in a single query, but the package (or maybe even R?) balks at having a parameter repeated.

ahh, I didn't know that, so scratch that 2nd checkbox. Thanks for correcting me.

If that's OK I'd like to not address that for now since it may require more substantial code changes)

Sure. And thanks for adding the zero-hits test.

@adam3smith
Copy link
Contributor Author

got it, done -- please take a look & let me know if anything else is missing.

The way I understand fq, it's mostly used for the facets available on the left, but there are some additional options such as the dateSort. I have no idea where/whether those are even documented.

@wibeasley wibeasley merged commit 012058e into IQSS:master Jan 7, 2020
@wibeasley
Copy link
Contributor

@adam3smith, looks great. Thanks again.

@pdurbin
Copy link
Member

pdurbin commented Jan 7, 2020

If it helps, "fq" is for "filter query".

The idea is that first you do a query with "q". Under the covers we pass a "*" (wildcard) as "q" when you are browsing Dataverse.

Then you use "fq" to refine or limit or narrow down your original "q". That is to say, there is always a "q" but the "fq" is optional. And as you have observed, you can have as many "fq"s as you want. You can only have one "q".

I hope this makes sense. You can also use boolean operators and such in both "q" and "fq" if you want. And operators like "TO" that @adam3smith is using with dateSort.

@adam3smith adam3smith deleted the patch-1 branch January 7, 2020 18:48
@wibeasley
Copy link
Contributor

Just a note in case this becomes a recurring problem. The two Ubuntu builds associated with this PR failed yesterday. I clicked 'Restart Job' on them today and they passed (one of them needed a 3rd try. Because I restarted it, I don't think that failing history is available anymore to insepct.

It had nothing to do with any R code in our repo. Apparently just some server timeout with the gpg key.

I'd been having similar trouble (with similar solutions) on another R package I've been developing today. But according to the Travis status, they've been 100% operational. https://www.traviscistatus.com/

https://travis-ci.org/IQSS/dataverse-client-r/jobs/633831998?

Error thrown yesterday:

Installing R
121.17s$ sudo add-apt-repository -y "ppa:marutter/rrutter3.5"
gpg: keyring `/tmp/tmpad_p2bj9/secring.gpg' created
gpg: keyring `/tmp/tmpad_p2bj9/pubring.gpg' created
gpg: requesting key B04C661B from hkp server keyserver.ubuntu.com
Error: retrieving gpg key timed out.
gpg: keyserver timed out
gpg: keyserver receive failed: keyserver error
The command "sudo add-apt-repository -y "ppa:marutter/rrutter3.5"" failed and exited with 1 during .

Error thrown today

Installing R
1.73s$ sudo add-apt-repository -y "ppa:marutter/rrutter3.5"
gpg: keyring `/tmp/tmp3vrq9j3r/secring.gpg' created
gpg: keyring `/tmp/tmp3vrq9j3r/pubring.gpg' created
gpg: requesting key B04C661B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp3vrq9j3r/trustdb.gpg: trustdb created
gpg: key B04C661B: public key "Launchpad PPA for marutter" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
66.78s$ sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"
Error: retrieving gpg key timed out.
gpg: keyring `/tmp/tmprn4clv38/secring.gpg' created
gpg: keyring `/tmp/tmprn4clv38/pubring.gpg' created
gpg: requesting key B04C661B from hkp server keyserver.ubuntu.com
gpg: /tmp/tmprn4clv38/trustdb.gpg: trustdb created
gpg: key B04C661B: public key "Launchpad PPA for marutter" imported
gpg: Total number processed: 1
gpg:               imported: 1  (RSA: 1)
OK
The command "sudo add-apt-repository -y "ppa:marutter/c2d4u3.5"" failed and exited with 1 during .
Your build has been stopped.

@pdurbin
Copy link
Member

pdurbin commented Jan 9, 2020

@wibeasley @adam3smith when one of you has a minute can you please create an issue over at https://github.com/IQSS/dataverse-jenkins/issues to add a job for dataverse-client-r to https://jenkins.dataverse.org ? I love, love, love Travis but it would be nice to have another view into if tests are passing or not. Belt and suspenders. 😄

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

3 participants