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

(feat) useSWRImmutable for fetching vitals concept metadata #604

Merged
merged 1 commit into from
Mar 11, 2022

Conversation

denniskigen
Copy link
Member

@denniskigen denniskigen commented Mar 11, 2022

Requirements

  • This PR has a title that briefly describes the work done, including the ticket number if there is a ticket.
  • My work conforms to the OpenMRS 3.0 Styleguide.
  • My work includes tests or is validated by existing tests.

Summary

Starting from version 1.0 of SWR, we can use the useSWRImmutable hook to mark a resource as immutable. This means that once data is fetched and cached, it will not get revalidated again.

The useVitalsConceptMetadata hook fetches data from the concept resource. This data is unlikely to change very often.

This PR modifies useVitalsConceptMetadata to use the useSWRImmutable hook for fetching data. It also removes an unused import from the vitals resource.

Since v1.0, SWR provides a helper hook useSWRImmutable to mark a resource as immutable. This means that once data is fetched and cached, it will not be requested again. Concept metadata is unlikely to change and as such revalidating is largely unnecessary.

This PR modifies the `useVitalsConceptMetadata` hook to use `useSWRImmutable` for data fetching.
@denniskigen denniskigen changed the title (feat)useSWRImmutable for fetching vitals concept metadata (feat) useSWRImmutable for fetching vitals concept metadata Mar 11, 2022
@github-actions
Copy link
Contributor

File size impact

Merging swr-immutable into master impact files as follow:

@openmrs/esm-form-entry-app (+8.02%)
Files new size
packages/esm-form-entry-app/dist/1.openmrs-esm-form-entry-app.js 1.48 MB (+109 kB / +7.92%) ↗️
packages/esm-form-entry-app/dist/openmrs-esm-form-entry-app.js 84.5 kB (+5.83 kB / +7.41%) ↗️
packages/esm-form-entry-app/dist/2.openmrs-esm-form-entry-app.js 46.1 kB (+5.19 kB / +12.69%) ↗️
Unmodified (1) 155 B (0 B / +0%) 👻
Total (4) 1.62 MB (+120 kB / +8.02%) ↗️
@openmrs/esm-generic-patient-widgets-app (+0.02%)
Files new size
packages/esm-generic-patient-widgets-app/dist/860.js 41.3 kB 👶
packages/esm-generic-patient-widgets-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-generic-patient-widgets-app/dist/openmrs-esm-generic-patient-widgets-app.js 9.35 kB (+6 B / +0.06%) ↗️
packages/esm-generic-patient-widgets-app/dist/5.js deleted (-40.5 kB)
Unmodified (11) 2.48 MB (0 B / +0%) 👻
Total (15) 2.99 MB (+745 B / +0.02%) ↗️
@openmrs/esm-patient-allergies-app (+0.03%)
Files new size
packages/esm-patient-allergies-app/dist/262.js 53.6 kB 👶
packages/esm-patient-allergies-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-allergies-app/dist/578.js deleted (-52.9 kB)
packages/esm-patient-allergies-app/dist/openmrs-esm-patient-allergies-app.js 12.2 kB (0 B / +0%) 👻
Unmodified (28) 2.15 MB (0 B / +0%) 👻
Total (32) 2.68 MB (+735 B / +0.03%) ↗️
@openmrs/esm-patient-appointments-app (+0.03%)
Files new size
packages/esm-patient-appointments-app/dist/883.js 30.5 kB 👶
packages/esm-patient-appointments-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-appointments-app/dist/761.js deleted (-29.8 kB)
packages/esm-patient-appointments-app/dist/openmrs-esm-patient-appointments-app.js 10.1 kB (0 B / +0%) 👻
Unmodified (21) 1.64 MB (0 B / +0%) 👻
Total (25) 2.15 MB (+735 B / +0.03%) ↗️
@openmrs/esm-patient-attachments-app (+0.04%)
Files new size
packages/esm-patient-attachments-app/dist/563.js 69.2 kB 👶
packages/esm-patient-attachments-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-attachments-app/dist/openmrs-esm-patient-attachments-app.js 9.72 kB (+3 B / +0.03%) ↗️
packages/esm-patient-attachments-app/dist/16.js deleted (-68.6 kB)
Unmodified (16) 1.15 MB (0 B / +0%) 👻
Total (20) 1.7 MB (+680 B / +0.04%) ↗️
@openmrs/esm-patient-banner-app (no impact)
Files new size
Unmodified (15) 1.07 MB (0 B / +0%) 👻
Total (15) 1.07 MB (0 B / +0%) 👻
@openmrs/esm-patient-biometrics-app (+0.03%)
Files new size
packages/esm-patient-biometrics-app/dist/860.js 41.2 kB 👶
packages/esm-patient-biometrics-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-biometrics-app/dist/openmrs-esm-patient-biometrics-app.js 10.6 kB (+6 B / +0.06%) ↗️
packages/esm-patient-biometrics-app/dist/5.js deleted (-40.5 kB)
Unmodified (18) 2.1 MB (0 B / +0%) 👻
Total (22) 2.62 MB (+745 B / +0.03%) ↗️
@openmrs/esm-patient-chart-app (+0.02%)
Files new size
packages/esm-patient-chart-app/dist/523.js 46.9 kB 👶
packages/esm-patient-chart-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-chart-app/dist/293.js deleted (-46.1 kB)
packages/esm-patient-chart-app/dist/openmrs-esm-patient-chart-app.js 18.3 kB (0 B / +0%) 👻
Unmodified (36) 3.14 MB (0 B / +0%) 👻
Total (40) 3.67 MB (+735 B / +0.02%) ↗️
@openmrs/esm-patient-clinical-view-app (+0.04%)
Files new size
packages/esm-patient-clinical-view-app/dist/231.js 466 kB (+410 kB / +727.67%) ↗️
packages/esm-patient-clinical-view-app/dist/459.js 57 kB 👶
packages/esm-patient-clinical-view-app/dist/821.js deleted (-466 kB)
packages/esm-patient-clinical-view-app/dist/openmrs-esm-patient-clinical-view-app.js 9.79 kB (0 B / +0%) 👻
Unmodified (15) 966 kB (0 B / +0%) 👻
Total (19) 1.5 MB (+674 B / +0.04%) ↗️
@openmrs/esm-patient-common-lib (no impact)

No file in @openmrs/esm-patient-common-lib group (see config below).

{
  "./packages/esm-patient-common-lib/dist/*.js": true,
  "./packages/esm-patient-common-lib/dist/*.css": true,
  "./packages/esm-patient-common-lib/dist/*.map": false,
  "./packages/esm-patient-common-lib/dist/*.txt": false,
  "./packages/esm-patient-common-lib/dist/*.json": false
}
@openmrs/esm-patient-conditions-app (+0.04%)
Files new size
packages/esm-patient-conditions-app/dist/406.js 33.6 kB 👶
packages/esm-patient-conditions-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-conditions-app/dist/609.js deleted (-32.9 kB)
packages/esm-patient-conditions-app/dist/openmrs-esm-patient-conditions-app.js 10.1 kB (0 B / +0%) 👻
Unmodified (22) 1.5 MB (0 B / +0%) 👻
Total (26) 2.01 MB (+735 B / +0.04%) ↗️
@openmrs/esm-patient-forms-app (+0.04%)
Files new size
packages/esm-patient-forms-app/dist/698.js 35.6 kB 👶
packages/esm-patient-forms-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-forms-app/dist/444.js deleted (-34.8 kB)
packages/esm-patient-forms-app/dist/openmrs-esm-patient-forms-app.js 12.8 kB (0 B / +0%) 👻
Unmodified (21) 1.56 MB (0 B / +0%) 👻
Total (25) 2.07 MB (+735 B / +0.04%) ↗️
@openmrs/esm-patient-immunizations-app (+0.04%)
Files new size
packages/esm-patient-immunizations-app/dist/398.js 37.1 kB 👶
packages/esm-patient-immunizations-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-immunizations-app/dist/986.js deleted (-36.4 kB)
packages/esm-patient-immunizations-app/dist/openmrs-esm-patient-immunizations-app.js 10.9 kB (0 B / +0%) 👻
Unmodified (18) 1.38 MB (0 B / +0%) 👻
Total (22) 1.9 MB (+735 B / +0.04%) ↗️
@openmrs/esm-patient-medications-app (+0.02%)
Files new size
packages/esm-patient-medications-app/dist/146.js 470 kB 👶
packages/esm-patient-medications-app/dist/openmrs-esm-patient-medications-app.js 9.82 kB (+2 B / +0.02%) ↗️
packages/esm-patient-medications-app/dist/506.js deleted (-469 kB)
Unmodified (17) 2.38 MB (0 B / +0%) 👻
Total (20) 2.85 MB (+627 B / +0.02%) ↗️
@openmrs/esm-patient-notes-app (+0.04%)
Files new size
packages/esm-patient-notes-app/dist/167.js 33.4 kB 👶
packages/esm-patient-notes-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-notes-app/dist/745.js deleted (-32.7 kB)
packages/esm-patient-notes-app/dist/openmrs-esm-patient-notes-app.js 10.5 kB (0 B / +0%) 👻
Unmodified (21) 1.53 MB (0 B / +0%) 👻
Total (25) 2.04 MB (+735 B / +0.04%) ↗️
@openmrs/esm-patient-programs-app (+0.04%)
Files new size
packages/esm-patient-programs-app/dist/694.js 40 kB 👶
packages/esm-patient-programs-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-programs-app/dist/828.js deleted (-992 B)
packages/esm-patient-programs-app/dist/574.js 992 B (-38.3 kB / -97.48%) ↘️
packages/esm-patient-programs-app/dist/655.js 1.69 kB (0 B / +0%) 👻
packages/esm-patient-programs-app/dist/openmrs-esm-patient-programs-app.js 9.72 kB (0 B / +0%) 👻
Unmodified (15) 1.48 MB (0 B / +0%) 👻
Total (21) 1.99 MB (+735 B / +0.04%) ↗️
@openmrs/esm-patient-test-results-app (+0.02%)
Files new size
packages/esm-patient-test-results-app/dist/860.js 50.7 kB 👶
packages/esm-patient-test-results-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-test-results-app/dist/682.js deleted (-50.1 kB)
packages/esm-patient-test-results-app/dist/openmrs-esm-patient-test-results-app.js 11 kB (0 B / +0%) 👻
Unmodified (25) 3.48 MB (0 B / +0%) 👻
Total (29) 4 MB (+674 B / +0.02%) ↗️
@openmrs/esm-patient-vitals-app (+0.02%)
Files new size
packages/esm-patient-vitals-app/dist/184.js 39.8 kB 👶
packages/esm-patient-vitals-app/dist/231.js 466 kB (+11 B / +0%) ↗️
packages/esm-patient-vitals-app/dist/251.js deleted (-39.1 kB)
packages/esm-patient-vitals-app/dist/openmrs-esm-patient-vitals-app.js 11.4 kB (0 B / +0%) 👻
Unmodified (22) 3.01 MB (0 B / +0%) 👻
Total (26) 3.53 MB (+735 B / +0.02%) ↗️
Generated by @jsenv/file-size-impact during Report bundle size#1970267160 on ea8b76b

@brandones brandones merged commit 4c2680e into master Mar 11, 2022
@brandones brandones deleted the swr-immutable branch March 11, 2022 18:32
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.

2 participants