Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check first week of next year, get period by date [LIBS-688] #74

Merged
merged 1 commit into from
Oct 9, 2024

Conversation

tomzemp
Copy link
Member

@tomzemp tomzemp commented Oct 2, 2024

See: https://dhis2.atlassian.net/jira/software/c/projects/LIBS/issues/LIBS-688

I've amended the logic of GetWeeklyFixedPeriodByDate to return the first period of the subsequent year if the requested date is after the end date of the the periods for the year. This logic mirrors the existing logic for returning the previous year's last week if requested date is before the start date of the first period of the year.

I guess a slightly safer implementation would also perform the check on the previous year/subsequent year's period to make sure the requested date is in range, but I assume it should not be necessary.

@tomzemp tomzemp requested review from kabaros and Mohammer5 October 2, 2024 14:36
@codecov-commenter
Copy link

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 91.27%. Comparing base (6770573) to head (8ba37e9).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #74      +/-   ##
==========================================
+ Coverage   91.25%   91.27%   +0.01%     
==========================================
  Files          56       56              
  Lines        1201     1203       +2     
  Branches      326      329       +3     
==========================================
+ Hits         1096     1098       +2     
  Misses        103      103              
  Partials        2        2              

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

@@ -102,13 +118,21 @@ describe('Gregorian Calendar period by date calculation', () => {
expect(actual?.id).toBe('2020BiW26')
})

it('should return "2020SunW1" for period type "BIWEEKLY" on "2020-01-01"', () => {
it('should return "2020BiW1" for period type "BIWEEKLY" on "2020-01-01"', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

just fixing typo in test description

@@ -136,7 +147,7 @@ describe('Ethiopic Calendar period by date calculation', () => {
expect(actual?.id).toBe('2014BiW26')
})

it('should return "2012SunW1" for period type "BIWEEKLY" on "2012-01-01"', () => {
it('should return "2012BiW1" for period type "BIWEEKLY" on "2012-01-01"', () => {
Copy link
Member Author

Choose a reason for hiding this comment

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

just fixing typo in test description

@@ -21,8 +21,8 @@ const getWeeklyFixedPeriodByDate: GetWeeklyFixedPeriodByDate = ({
startingDay: 1,
})

// if start date of first period of year is after current date get last
// period of last year
// if current date is before start date of first period of year
Copy link
Member Author

Choose a reason for hiding this comment

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

I just modified the language of the comment here, so that it more closely matched the actual logical operation performed below

@tomzemp tomzemp merged commit 8662fe0 into main Oct 9, 2024
7 checks passed
dhis2-bot added a commit that referenced this pull request Oct 9, 2024
## [1.3.2](v1.3.1...v1.3.2) (2024-10-09)

### Bug Fixes

* check first week of subsequent year when geting period by date [LIBS-688] ([#74](#74)) ([8662fe0](8662fe0))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 1.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

dhis2-bot added a commit that referenced this pull request Nov 21, 2024
# [2.0.0-alpha.6](v2.0.0-alpha.5...v2.0.0-alpha.6) (2024-11-21)

### Bug Fixes

* check first week of subsequent year when geting period by date [LIBS-688] ([#74](#74)) ([8662fe0](8662fe0))
@dhis2-bot
Copy link
Contributor

🎉 This PR is included in version 2.0.0-alpha.6 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging this pull request may close these issues.

4 participants