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

getVersionFileCounts API endpoints extended to support filtering by criteria #9985

Merged
merged 10 commits into from Oct 13, 2023

Conversation

GPortas
Copy link
Contributor

@GPortas GPortas commented Oct 9, 2023

What this PR does / why we need it:

Extended the getVersionFileCounts endpoint (/api/datasets/{id}/versions/{versionId}/files/counts) to support filtering by criteria.

In particular, the endpoint now accepts the following optional criteria query parameters:

  • contentType
  • accessStatus
  • categoryName
  • tabularTagName
  • searchText

This filtering criteria is the same as the one for the getVersionFiles endpoint.

Which issue(s) this PR closes:

Special notes for your reviewer:

IT case added for each of the supported query parameters, so a very extensive manual test is not necessary.

DatasetVersionFilesServiceBean has been refactored to make the filtering criteria logic reusable for multiple endpoints.

Suggestions on how to test this:

Create a dataset and upload files. Once you have uploaded the files, call the endpoint with the new criteria parameters to test that the returned counts are correct.

Example for content type:

curl http://localhost:8080/api/datasets/2/versions/:latest/files/counts?contentType=image/png
If the dataset is not public, you will need to add the API key to the call.

Does this PR introduce a user interface change? If mockups are available, please link/include them here:

No

Is there a release notes update needed for this change?:

Yes

Additional documentation:

N/A

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

1 similar comment
@github-actions
Copy link

github-actions bot commented Oct 9, 2023

📦 Pushed preview images as

ghcr.io/gdcc/dataverse:9907-file-counts-with-criteria
ghcr.io/gdcc/configbaker:9907-file-counts-with-criteria

🚢 See on GHCR. Use by referencing with full name as printed above, mind the registry name.

@GPortas GPortas changed the title 9907 file counts with criteria getVersionFileCounts API endpoints extended to support filtering by criteria Oct 9, 2023
@GPortas GPortas marked this pull request as ready for review October 9, 2023 09:28
@GPortas GPortas added this to Ready for Review ⏩ in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) via automation Oct 9, 2023
@GPortas GPortas added the SPA These changes are required for the Dataverse SPA label Oct 9, 2023
Base automatically changed from 9714-files-api-extension-filters to develop October 9, 2023 17:45
@sekmiller sekmiller self-assigned this Oct 10, 2023
@sekmiller sekmiller moved this from Ready for Review ⏩ to In Review 🔎 in IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) Oct 10, 2023
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from In Review 🔎 to Ready for QA ⏩ Oct 11, 2023
@sekmiller sekmiller removed their assignment Oct 11, 2023
@kcondon kcondon self-assigned this Oct 12, 2023
@kcondon
Copy link
Contributor

kcondon commented Oct 12, 2023

@GPortas
Issues found:

  1. Not able to operate on deaccessioned dataset, says version not found. Owner/editor should be able to, not others.
  2. API endpoint without contentType arg seems to wait on command prompt until hit return again. Doesn't work that way with contentType. More of a curiosity but seems like something not quite right.

@GPortas
Copy link
Contributor Author

GPortas commented Oct 13, 2023

@kcondon

Thank you for your feedback.

  1. Support for deaccessioned datasets is included in the other PR, this one doesn't contain those changes, but it should work as you describe when merging.

  2. I think something weird is going on with double quotes. Can you try with these examples?

curl http://localhost:8080/api/datasets/<DATASED_ID>/versions/:latest/files/counts
curl http://localhost:8080/api/datasets/<DATASED_ID>/versions/:latest/files/counts?contentType=image/png

These calls are working for me.

@kcondon
Copy link
Contributor

kcondon commented Oct 13, 2023

@GPortas Thanks. Yes, I'd run into the quotes thing in some way with Jim. Exchanging single quotes for double some times works: curl 'http://localhost:8080/api/datasets/:persistentId/versions/:latest/nts?persistentId=doi:10.70122/FK2/IHEHUV&contentType=text/tab-separated-values'
{"status":"OK","data":{"total":1,"perContentType":{"text/tab-separated-values":1},"perCategoryName":{},"perTabularTagName":{},"perAccessStatus":{"Public":1}}}

I thought I'd tried that here already but it must have been the other pr. OK, will merge, seeing that deaccession is addressed in the other pr but note there is a permissions issue around the endpoint in the other pr for deaccessioned datasets.

@kcondon kcondon merged commit f354325 into develop Oct 13, 2023
16 of 18 checks passed
IQSS/dataverse (TO BE RETIRED / DELETED in favor of project 34) automation moved this from QA ✅ to Done 🚀 Oct 13, 2023
@kcondon kcondon deleted the 9907-file-counts-with-criteria branch October 13, 2023 13:13
@pdurbin pdurbin added this to the 6.1 milestone Oct 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
SPA These changes are required for the Dataverse SPA
Projects
No open projects
Development

Successfully merging this pull request may close these issues.

[Spike - API] Extend the file counts endpoint to return counts based on selected filters and search criteria
4 participants