Skip to content

fix: correct previous monthly period for December [DHIS2-21584]#96

Draft
eirikhaugstulen wants to merge 2 commits into
mainfrom
eh/fix-december-previous-monthly-period
Draft

fix: correct previous monthly period for December [DHIS2-21584]#96
eirikhaugstulen wants to merge 2 commits into
mainfrom
eh/fix-december-previous-monthly-period

Conversation

@eirikhaugstulen

@eirikhaugstulen eirikhaugstulen commented May 30, 2026

Copy link
Copy Markdown

Summary

Fixes DHIS2-21584 by preventing getAdjacentFixedPeriods from returning the current monthly period when stepping backwards from December.

Root Cause

Monthly backward traversal used the period start date year and a slice boundary based on the first later period. For December, there is no later monthly period in the generated year, so the boundary calculation could include the current December period instead of ending before it.

Changes

  • Use the year encoded in the period id when walking backwards through monthly periods.
  • Treat the first current-or-following monthly period as the exclusive end boundary when collecting previous periods.
  • Add a Gregorian regression test for stepping back from 202412 to 202411.

Validation

  • yarn test get-adjacent-fixed-periods.gregorian.spec.ts --watchAll=false --runInBand --watchman=false
  • yarn test get-adjacent-fixed-periods --watchAll=false --runInBand --watchman=false
  • yarn d2-style check src/period-calculation/get-adjacent-fixed-periods/get-adjacent-fixed-periods.gregorian.spec.ts src/period-calculation/get-adjacent-fixed-periods/get-adjacent-monthly-fixed-periods.ts

@codecov-commenter

codecov-commenter commented May 30, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.88%. Comparing base (d202f08) to head (aa5593a).

Additional details and impacted files
@@           Coverage Diff           @@
##             main      #96   +/-   ##
=======================================
  Coverage   90.87%   90.88%           
=======================================
  Files          57       57           
  Lines        1249     1250    +1     
  Branches      352      353    +1     
=======================================
+ Hits         1135     1136    +1     
  Misses        112      112           
  Partials        2        2           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@eirikhaugstulen
eirikhaugstulen force-pushed the eh/fix-december-previous-monthly-period branch from 1d0bfd1 to 9465c51 Compare May 30, 2026 14:36
@eirikhaugstulen
eirikhaugstulen changed the base branch from fix/weekly-period-display-name to main May 30, 2026 14:37
@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.

2 participants