ropensci / europepmc

R Interface to Europe PMC RESTful Web Service
https://docs.ropensci.org/europepmc
27 stars 8 forks source link

epmc_search: populate the hit_count attribute even with zero results #58

Open arvi1000 opened 1 month ago

arvi1000 commented 1 month ago

This addresses issue 56, and now sets the hit_count attribute even when no results found. Note that we can't return a NULL result anymore, since NULL can't have attributes, so instead we return an empty tibble

arvi1000 commented 1 month ago

I see failing tests, but it appears to failing on this line, which asserts that the following should return 50 rows:

 a <- epmc_db("12368864", db = "uniprot", limit = 50)

However in the current cran version, it seems to only return 10 rows:

> library(europepmc)
> epmc_db("12368864", db = "uniprot", limit = 50)
10 records found. Returning 10

So perhaps this test needs an update and the change in the PR is not the issue? I welcome a reviewer's comments, thanks

arvi1000 commented 1 month ago

Looking at the API directly, 10 does seem to be the current correct number of hits returned. Using source = 'med' as that's the default and nothing explicit is passed in the test line

https://www.ebi.ac.uk/europepmc/webservices/rest/med/12368864/databaseLinks?database=UNIPROT&page=1&pageSize=50&format=json

I'm happy to update the test as part of this PR if that suits (e.g. limit = 7 and then test that 7 records come back)

arvi1000 commented 2 weeks ago

I changed the test mentioned in the comment above. I also updated the test relating to zero result queries, since they now return blank tibbles with hit_count attr = 0 instead of NULL. So now all tests pass