fix: apply org unit hierarchy in event and enrollment pivot tables - #1846
Draft
HendrikThePendric wants to merge 3 commits into
Draft
HendrikThePendric wants to merge 3 commits into
HendrikThePendric wants to merge 3 commits into
Conversation
HendrikThePendric
marked this pull request as draft
September 16, 2026 14:18
metaData.items entries carry only a name, so item.uid is undefined on every analytics endpoint. Reading the id from there left itemIds as an array of undefined, which broke the row lookup and rendered every value cell empty whenever showHierarchy was on. Take the ids from ouDimension.itemIds, where they already live, and keep them paired with their items through the sort. sortByHierarchy becomes a comparator so the pairs can sort together. The hierarchy spec fixture carried a uid on its items, which no endpoint returns; correcting it is what exposed this. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
|
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



Implements DHIS2-22094
Description
Two fixes in
PivotTableEngineso org unit hierarchy can work in event and enrollment pivot tables.The org unit dimension was found by literal key.
allByDimension['ou']never matched a stage-qualified dimension (<stageId>.ou), and matched at most one org unit dimension per layout. It now matches any org unit dimension — bydimensionTypewhere the response provides it, by unqualified dimension id otherwise.applyHierarchylooked for each org unit's id in the wrong place.metaData.itemsis a map keyed by id, and its values hold only a name — soitem.uidis undefined. The id was already to hand:buildDimensionLookupstores it initemIds, positionally paired withitems. Reading it from the item instead overwroteitemIdswith[undefined, …], which broke the row lookup and left every value cell empty whenevershowHierarchywas on. Ids now come fromitemIdsand stay paired with their items through the sort.Fix 2 is pre-existing and independent of fix 1, and needs no backend change — the response was never missing anything. Checked on 2.41.10, 2.42.6, 2.43.1 and 2.44-SNAPSHOT:
metaData.itemsvalues are{name: 'Bo'}on both/api/analyticsand the event/enrollment aggregate endpoints.Dependency chain
This PR on its own changes nothing user-visible. The feature needs three parts:
oushowHierarchy=trueon pivot requestsEnrollment pivots need 2 + 3 only — they already send a bare
ou.Event pivots need all three; without 1 the backend returns no hierarchy to apply.
Draft until the chain is verified end to end.
🤖 Generated with Claude Code