Skip to content

fix: send showHierarchy for pivot table analytics requests - #384

Merged
HendrikThePendric merged 3 commits into
masterfrom
fix/add-showHierarchy-to-pt-analytics-request
Sep 22, 2026
Merged

HendrikThePendric merged 3 commits into
masterfrom
fix/add-showHierarchy-to-pt-analytics-request

Conversation

@HendrikThePendric

@HendrikThePendric HendrikThePendric commented Sep 16, 2026

Copy link
Copy Markdown
Collaborator

Implements DHIS2-22094

Description

"Display organisation unit hierarchy" is offered in the pivot table Style tab but has no effect. The option reached the pivot engine, but showHierarchy was never sent to the analytics API, so no ouNameHierarchy came back.

The app now sends showHierarchy when the option is on, and adds it to the request identity so toggling refetches. It is set on the pivot adapter rather than in ANALYTICS_OPTIONS, which the line list shares and which must not start sending the parameter.

That is all this app can do. The option still needs @dhis2/analytics to return different data before it works end to end — and, for event pivots, the backend to return the hierarchy at all.

Dependency chain

# Where What
1 dhis2-core DHIS2-22119 — no hierarchy metadata returned for a stage-qualified ou (#25259)
2 dhis2/analytics#1846 applies the hierarchy to event and enrollment pivots, and requests the metadata it needs
3 this PR sends showHierarchy=true

Enrollment pivots work once 2 merges. Event pivots additionally need 1.

Merging 3 without 2 would make enrollment pivots worse than today: the option would blank the value grid rather than do nothing.

How to verify

Test against an instance built from dhis2-core#25259, such as https://dev.im.dhis2.org/org-unit-hierarchy. This PR has a d2-ci build of analytics#1846 pinned so the full solution can be tested using the Netlify link below as follows:

  • an EVENT pivot with the stage org unit on rows, hierarchy off → 13 districts, values populated
  • same pivot, hierarchy on → same 13 rows with ancestor paths (Sierra Leone / Bo), byte-identical values
  • at chiefdom level, where hierarchy order and alphabetical order disagree, rows re-sort into hierarchy order (Bo / Wonde is followed by Bombali / Biriwa) and every value cell stays populated; of the org units present in both renderings, all 54 carry the same value
  • toggling the option off and on again refetches, and showHierarchy=true is on the request only while it is on

Quality checklist

🤖 Generated with Claude Code | edited by @HendrikThePendric

The "Display organisation unit hierarchy" option reached the pivot table
engine but was never sent to the analytics API, so no ouNameHierarchy
came back and the option had no effect.

Send showHierarchy when the option is on, and include it in the request
identity so toggling it refetches. It is set on the pivot adapter rather
than in ANALYTICS_OPTIONS, which the line list shares and which must not
start sending the parameter.

Points @dhis2/analytics at a d2-ci build for testing; to be replaced with
a released version once that PR is merged.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
@dhis2-bot

Copy link
Copy Markdown
Contributor

🚀 Deployed on https://pr-384.event-visualizer.netlify.dhis2.org

@dhis2-bot
dhis2-bot temporarily deployed to netlify September 16, 2026 14:57 Inactive
@HendrikThePendric
HendrikThePendric marked this pull request as ready for review September 17, 2026 14:40
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 17, 2026 14:41 Inactive
edoardo
edoardo previously approved these changes Sep 21, 2026
@dhis2-bot
dhis2-bot temporarily deployed to netlify September 21, 2026 13:41 Inactive
@sonarqubecloud

Copy link
Copy Markdown

@HendrikThePendric
HendrikThePendric merged commit d7597f8 into master Sep 22, 2026
20 checks passed
@HendrikThePendric
HendrikThePendric deleted the fix/add-showHierarchy-to-pt-analytics-request branch September 22, 2026 08:03

This branch was previously deployed

1 inactive deployment
netlify 8b593dac Deployed Sep 21, 2026 by dhis2-bot
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