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): Add limit parameter to API calls to return full chunk results in useConcepts hook #458

Merged
merged 2 commits into from
Jan 17, 2025

Conversation

usamaidrsk
Copy link
Member

@usamaidrsk usamaidrsk commented Jan 17, 2025

Requirements

  • This PR has a title that briefly describes the work done including the ticket number. If there is a ticket, make sure your PR title includes a conventional commit label. See existing PR titles for inspiration.
  • My work conforms to the OpenMRS 3.0 Styleguide and design documentation.
  • My work includes tests or is validated by existing tests.

Summary

The useConcepts hook currently has two issues with result limits:

  • The chunk size is hardcoded to 100 instead of using the configurable webservices.rest.maxResultsAbsolute global property
  • API calls are only returning 50 results due to webservices.rest.maxResultsDefault, as the limit parameter is not being passed

Fixed by:

  • Fetching webservices.rest.maxResultsAbsolute global property to determine chunk size
  • Adding limit parameter to concept API calls to ensure full result set is returned
  • Adding fallback chunk size of 100 if global property fetch fails

Screenshots

Related Issue

Other

@usamaidrsk usamaidrsk requested a review from vasharma05 January 17, 2025 07:19
@usamaidrsk usamaidrsk changed the title (fix): Add global property limit handling in useConcepts hook (fix): Add limit parameter to API calls to return full chunk results in useConcepts hook Jan 17, 2025
Copy link

github-actions bot commented Jan 17, 2025

Size Change: -264 kB (-17.23%) 👏

Total Size: 1.27 MB

Filename Size Change
dist/219.js 0 B -264 kB (removed) 🏆
ℹ️ View Unchanged
Filename Size Change
dist/151.js 382 kB 0 B
dist/225.js 2.58 kB 0 B
dist/260.js 114 kB 0 B
dist/277.js 11.9 kB 0 B
dist/300.js 645 B 0 B
dist/335.js 968 B 0 B
dist/353.js 3.02 kB 0 B
dist/41.js 3.37 kB 0 B
dist/422.js 3.05 kB 0 B
dist/499.js 2.51 kB 0 B
dist/540.js 2.63 kB 0 B
dist/55.js 758 B 0 B
dist/606.js 2.24 kB 0 B
dist/635.js 14.4 kB 0 B
dist/658.js 1.85 kB 0 B
dist/727.js 87.2 kB 0 B
dist/891.js 264 kB 0 B
dist/979.js 6.87 kB 0 B
dist/99.js 691 B 0 B
dist/993.js 3.09 kB 0 B
dist/main.js 357 kB 0 B
dist/openmrs-esm-form-engine-lib.js 3.8 kB +2 B (+0.05%)

compressed-size-action

@@ -28,7 +28,9 @@ export function useConcepts(references: Set<string>): {
const start = index * chunkSize;
const end = start + chunkSize;
const referenceChunk = Array.from(references).slice(start, end);
return `${restBaseUrl}/concept?references=${referenceChunk.join(',')}&v=${conceptRepresentation}`;
return `${restBaseUrl}/concept?references=${referenceChunk.join(
Copy link
Member

Choose a reason for hiding this comment

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

As defined in the PR description, the chunkSize must be fetched from the global properties, endpoint ${restBaseUrl}/systemsetting/<setting_name>

@usamaidrsk usamaidrsk merged commit e243184 into main Jan 17, 2025
6 checks passed
@usamaidrsk usamaidrsk deleted the fix-useConcepts branch January 17, 2025 10:45
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