Skip to content

chore: [DHIS2-20995] Limit fields param in the api requests#4559

Open
henrikmv wants to merge 15 commits into
masterfrom
hv/chore/DHIS2-20995_limit-fields-param
Open

chore: [DHIS2-20995] Limit fields param in the api requests#4559
henrikmv wants to merge 15 commits into
masterfrom
hv/chore/DHIS2-20995_limit-fields-param

Conversation

@henrikmv
Copy link
Copy Markdown
Contributor

@henrikmv henrikmv commented May 12, 2026

DHIS2-20995

Trims fields parameters across 20 API queries to request only what's actually used.

Field-by-field changes

Org unit queries

File Removed Why safe
orgUnitFieldForForms.epics publicAccess, access, lastUpdated, children[...] Result flows through the FILTERED_FORM_FIELD_ORG_UNITS_RETRIEVED reducer into SingleOrgUnitSelectField.component.tsx:48-50, which reads only id, displayName, path
OrgUnitField (FormFields/New) displayName, publicAccess, access, lastUpdated, children[...] Passed straight to OrgUnitTree which renders nodes lazily; the field-trimmed query only needs id,path to seed the tree
OrgUnitTree :all wildcard, root-level id,displayName,path Tree/index.tsx:126 renders only label (=displayName) and value (=path) from the children[...] subtree
TeiSearch / searchOrgUnitSelector (×2) publicAccess, access, lastUpdated, children[...] Same path as orgUnitFieldForForms — result lands in SingleOrgUnitSelectField.component.tsx:48-50

TEI / Event fetches

File Removed Why safe
ExistingTEILoader *attributes[attribute,value] ExistingTEIContents.component.tsx:37-41 renders only the attribute values in a CardList
useEnrollment createdBy, updatedBy WidgetEnrollment.component.tsx reads only status, followUp, enrolledAt, occurredAt, orgUnit, geometry, updatedAt (lines 77-177) — never createdBy / updatedBy
useLinkedEventByOriginId Stray * inside the to[event[...]] subtree getDataEntryDetails.ts:23-48 reads only occurredAt, scheduledAt, orgUnit, status from the linked event; the * was an asymmetric over-fetch (from side didn't have it)
SearchForm.epics (×2) trackedEntityType from result fields CardListItem.component.tsx:135 derives program from enrollments[0].program; the search result's trackedEntityType was never read (it's known from the query input)
TrackerWorkingLists/getEventListData (createApiTEIsQueryArgs) enrollments[status,orgUnit,enrolledAt] (kept enrollments[enrollment]) Only the enrollment ID is used to correlate events back to TEIs; status / orgUnit / enrolledAt come from the enrollment widget's own fetch

Access / category metadata

File Removed Why safe
getCategoriesDataFromEvent access (defaults) → access[data[write]] getCategoriesDataFromEvent.ts:63 reads only option.access.data.write
useRelationshipTypes access.read, access.write (kept access.data[read,write]) All 26 consumer call-sites check .data.read / .data.write only; outer object-level access is never read
loadCategories access[*]access[data[write]] Cached category options are only used for access.data.write checks in the category-options selector path

Cached program metadata (IndexedDB)

File Removed Why safe
storePrograms description, userRoles[id,displayName], narrowed access[*]access[data[read,write]] No consumer in capture-app reads program.description or program.userRoles from the cached program; only access.data.* is checked
storeProgramIndicators code, shortName, displayDescription (kept description) No consumer reads programIndicator.code, programIndicator.shortName, or programIndicator.displayDescription
storeProgramRules description No consumer reads programRule.description
storeRelationshipTypes referral No consumer reads relationshipType.referral

Working lists (listing vs. download split)

Split listing vs. download in working lists.** Working list endpoints used to fetch the full record because Working list downloads needed it — so every page load fetched everything. Now LISTING_FIELDS is slim for in-app rendering; DOWNLOAD_FIELDS is full, applied only on the Working list download.

File Listing fields (new slim) Download fields (full, on CSV only)
EventWorkingLists/getEventListData event,program,programStage,status,occurredAt,orgUnit,
assignedUser[uid,username,firstName,surname],
dataValues[dataElement,value]
dataValues,occurredAt,event,status,orgUnit,
program,programType,updatedAt,createdAt,assignedUser
TrackerWorkingLists/getEventListData event,status,program,enrollment,trackedEntity,
occurredAt,scheduledAt,orgUnit,
assignedUser[uid,username,firstName,surname],
dataValues[dataElement,value]
(was *)
*
getTeiListData trackedEntity,createdAt,inactive,
attributes[attribute,value],
programOwners[orgUnit,program]
(was :all,!relationships,programOwners[...])
:all,!relationships,
programOwners[orgUnit,program]

@github-actions
Copy link
Copy Markdown

github-actions Bot commented May 12, 2026

@henrikmv henrikmv added testing and removed testing labels May 12, 2026
@henrikmv henrikmv added testing and removed testing labels May 12, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 7 additional findings.

Open in Devin Review

@henrikmv henrikmv added testing and removed testing labels May 13, 2026
@henrikmv henrikmv added testing and removed testing labels May 14, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

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

Devin Review found 6 new potential issues.

View 5 additional findings in Devin Review.

Open in Devin Review

@henrikmv henrikmv added testing and removed testing labels May 14, 2026
@henrikmv henrikmv marked this pull request as ready for review May 15, 2026 11:06
@henrikmv henrikmv requested a review from a team as a code owner May 15, 2026 11:06
@henrikmv henrikmv added testing and removed testing labels May 15, 2026
Copy link
Copy Markdown
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

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

Good job! The PR description was very helpful for quickly understanding how the field parameters are used 🙌 . I only added one minor comment.

@sonarqubecloud
Copy link
Copy Markdown

@henrikmv henrikmv added testing and removed testing labels May 18, 2026
@henrikmv henrikmv requested a review from simonadomnisoru May 18, 2026 17:57
Copy link
Copy Markdown
Contributor

@simonadomnisoru simonadomnisoru left a comment

Choose a reason for hiding this comment

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

Niice 🥳 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants