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

Add _count paramater support in search command. #100

Merged
merged 6 commits into from
Sep 5, 2024
Merged

Conversation

hossenlopp
Copy link
Contributor

@hossenlopp hossenlopp commented May 22, 2024

Summary

Add support for _count parameter for search operations.

Note: I've left the loadBundles bundle loader script piece in for now, but I think we should potentially remove that since other functionality has been added that takes its place. We may want to keep it for the moment ahead of the connectathon in case it's useful (maybe we pull it off into another branch? or maybe just make sure the commit isn't deleted?).

New behavior

The '_count' parameter can be used to limit the number of resources pulled from a search (default 50), while page can be used to indicate what page of search results (default 1st page).

Code changes

  • README.md update
  • dbOperations.ts - update to findResourcesWithQuery and findResourceElementsWithQuery to use pagination and appropriately aggregate results with an aggregation pipeline (necessary to get the count and results in the same request)
  • requestSchemas.ts - update to allow '_count' and 'page' parameters
  • LibraryService.ts and MeasureService.ts - updates to create pagination links
  • bundleUtils.ts - createPaginationLinks function
  • queryUtils.ts - handle creating limit and skip values in mongo query for use in pagination
  • Added _count/page tests and updated queryUtils test to match new functionality

Should probably be removed:

  • loadBundles script and package.json update to run it

Testing guidance

  • npm run check in service folder
  • Use insomnia to execute search queries with various '_count', 'page', and lack thereof

@elsaperelli elsaperelli self-requested a review May 23, 2024 19:48
@elsaperelli elsaperelli self-assigned this May 23, 2024
@lmd59 lmd59 force-pushed the count-and-bundle-loader branch 2 times, most recently from b9b631d to a8fcede Compare August 30, 2024 15:33
@lmd59 lmd59 marked this pull request as ready for review August 30, 2024 15:51
Copy link
Contributor

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looking good! Just some small comments and one potential issue with the Library endpoint when the database is populated with bundles from the may-2024-connectathon repository.

hossenlopp and others added 5 commits September 4, 2024 21:10
needs tests fix

Most tests fixed

Clean up mongo query and fix aggregation

cleanup and add _count tests

Update comment
Simplify db operation return structure
@lmd59 lmd59 force-pushed the count-and-bundle-loader branch from 91f3e7d to 1d51f7f Compare September 5, 2024 01:10
Copy link
Contributor

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

One small comment!

Co-authored-by: Elsa Perelli <[email protected]>
Copy link
Contributor

@elsaperelli elsaperelli left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🥳

@lmd59 lmd59 merged commit f75288e into main Sep 5, 2024
2 checks passed
@elsaperelli elsaperelli deleted the count-and-bundle-loader branch September 5, 2024 17:56
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.

3 participants