Skip to content

perf: skip org unit/period resolution in dimension recommendations [2.40]#24277

Open
jason-p-pickering wants to merge 1 commit into
2.40from
perf-recommendations-skip-ou-dimension-2.40
Open

perf: skip org unit/period resolution in dimension recommendations [2.40]#24277
jason-p-pickering wants to merge 1 commit into
2.40from
perf-recommendations-skip-ou-dimension-2.40

Conversation

@jason-p-pickering

Copy link
Copy Markdown
Contributor

Summary

Backport of master commit f61988aa36 (PR #24264) onto 2.40.

/api/dimensions/recommendations resolved every dimension on the request via DataQueryService.getFromRequest, including ou:LEVEL-*. On a large hierarchy this hydrates all org units at the level as full entities and sorts them (~4.5s CPU, ~3.2 GB allocated in production profiling) — but getRecommendedDimensions only reads the data (dx) dimension's data elements / program indicators, so the org-unit (and period) resolution is pure discarded work.

This scopes the request to the dx dimension before resolving, so getFromRequest never resolves/hydrates the unused dimensions. Behaviour-equivalent for the sole caller (DimensionController sets only the dimension param); no change to DataQueryService / getOrganisationUnitsAtLevels callers.

2.40 adaptations vs the master commit

  • DATA_X_DIM_ID is imported from DimensionalObject — 2.40 predates the DimensionConstants extraction.
  • The unit test mocks CurrentUserService (2.40's service still reads the current user via the injected field) instead of master's static CurrentUserUtil / UserDetails.empty() setup.

Testing

  • DefaultAnalyticsDimensionServiceTest#getRecommendedDimensionsResolvesOnlyDataDimension (new) — asserts only the dx dimension reaches getFromRequest; ou/pe are stripped. Passes.
  • Spotless clean.

Context: 2.40 was deprecated; this PR exists so the fix can be cleanly cherry-picked into downstream 2.40-based branches and is ready for any future 2.40 EOL update.

🤖 Generated with Claude Code

….40]

Backport of master commit f61988a (PR #24264) onto 2.40.

The /api/dimensions/recommendations endpoint resolved every dimension on
the request via DataQueryService.getFromRequest, including ou:LEVEL-*.
On a large hierarchy this hydrates all org units at the level as full
entities and sorts them (~4.5s CPU, ~3.2 GB allocated in production
profiling) -- but getRecommendedDimensions only reads the data (dx)
dimension's data elements/program indicators, so the org unit (and
period) resolution is discarded.

Scope the request to the dx dimension before resolving, so getFromRequest
never resolves/hydrates the unused dimensions. Behaviour-equivalent for the
sole caller (DimensionController sets only the dimension param), with no
change to DataQueryService/getOrganisationUnitsAtLevels callers.

2.40 adaptations vs the master commit:
- DATA_X_DIM_ID is imported from DimensionalObject (2.40 predates the
  DimensionConstants extraction).
- The unit test mocks CurrentUserService (2.40's service still reads the
  current user via the injected field) instead of master's static
  CurrentUserUtil / UserDetails.empty() setup.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

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.

1 participant