Repository navigation
fix(versions): group this week's versions correctly on Sundays - #4993
vishalhabib99 wants to merge 1 commit into
Conversation
On Sundays, getHeading treated today as the Sunday that ends the previous week. Versions from Monday to Friday of the current week were labeled "Last Week", and versions from the previous week were labeled "This Month". Count back to the previous Sunday from Monday instead.
|
Tick the box to add this pull request to the merge queue (same as
|
|
No actionable comments were generated in the recent review. WalkthroughThe version menu now treats Sunday as the end of the previous week when calculating version group headings. A test checks the resulting headings and counts for a fixed Sunday date. ChangesVersion Grouping
Estimated code review effort: 2 (Simple) | ~5 minutes Change: Bug fix · Severity of issue fixed: Low Suggested reviewers: Merge Risk:
|
VersionsMenugroups versions under headings withgetHeading. The existing test shows the intended weeks start on Monday: on Thursday 2019-06-20, Monday and Tuesday get weekday headings and Sunday 2019-06-16 falls under "Last Week".On a Sunday this breaks.
currentSundayisgetDate() - getDay(), andgetDay()is 0 on Sunday, socurrentSundaybecomes today. Every version from earlier in the current week then matchesgetDate() <= currentSundayand is labeled "Last Week". The real previous week matches<= currentSunday - 7and is labeled "This Month". The headings jump back to the right values on Monday.Fix
Count days since Monday (
(getDay() + 6) % 7) and step back one more day to reach the Sunday that ended the previous week. Monday to Saturday give the same value as before. Only Sunday changes.Before / after
New test: today is Sunday 2019-06-23, with versions from Sunday the 23rd back to June 1.
Before (master):
After:
Today, Yesterday, Friday, Monday, Last Week (16th and 10th), This Month (9th and 1st), which matches how a Thursday groups the same days.Tests
yarn test src/elements/content-sidebar/versions/: 13 suites, 158 tests pass. The new test fails on master.eslintandprettier --checkpass on the changed files.Summary by CodeRabbit
Bug Fixes
Tests