fix(date-range): compute the default range lazily to avoid a stale year#4842
Conversation
|
@Anexus5919 is attempting to deploy a commit to the jhasourav07's projects Team on Vercel. A member of the Team first needs to authorize it. |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Great logical fix! Lazily computing the default date range prevents stale year bugs when the application instance runs across New Year's boundaries. Approving!
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the PR. I've reviewed the changes and they look good to me.
I'm happy to approve this. Great job!
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the contribution. I went through the changes and the overall approach looks good, but there are a few issues that should be addressed before this can be merged. Most of the concerns are related to correctness and maintainability.
- There are merge conflicts with the base branch. Please resolve them to ensure existing functionality isn't broken.
Once these issues are addressed, I'll be happy to take another look. Thanks again for the contribution.
fd898d4 to
2951fd2
Compare
|
@Aamod007 @JhaSourav07 Could you please take another look when you get a chance? Thanks! |
|
🚨 Hey @Anexus5919, the CI Pipeline is failing on this PR and it has been marked as Please fix the issues before this can be reviewed. Here's how: 1. Run checks locally before pushing: npm run format:check # Check Prettier formatting
npm run lint # Run ESLint
npm run typecheck # TypeScript type check
npm run test # Run unit tests (Vitest)
npm run build # Verify production build passes2. Auto-fix common issues: npm run format # Auto-fix formatting with Prettier
npm run lint -- --fix # Auto-fix lint errors where possible3. Check the full failure log here: Once you push a fix and the CI passes, the |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for the contribution. The overall approach looks good, but the CI pipeline is currently failing. Please run the checks (like npm run format, npm run lint, and npm run test) locally to identify and fix the issues. Let me know once it's green!
4ede7fe to
d27b5b7
Compare
|
@Aamod007 Done. Please have a re-review on this. Thanks! |
Aamod-Dev
left a comment
There was a problem hiding this comment.
Thanks for fixing the CI pipeline! Approving.
|
🎉 Congratulations @Anexus5919! Your PR has been successfully merged. 🚀 Thank you for contributing to CommitPulse. Your work helps us build a better tool for the community.
Keep building! 💻✨ |
Description
Fixes #4841
utils/dateRange.tsexposed the fallback range as a constant whose year was captured once at module load (new Date().getUTCFullYear()insideDEFAULT_DATE_RANGE). That value goes stale after a New Year rollover in a long-lived process, andformatDateRangereturned it for missing or invalid years, inheriting the staleness.This change replaces the constant with a lazy function
getDefaultDateRange()that computes the current-year range each time it is called, so the value is always correct.formatDateRangenow callsgetDefaultDateRange()for its empty and invalid-year fallbacks. TheDateRangeinterface was moved above the function it types.DEFAULT_DATE_RANGEhad no production callers (only the module and its test referenced it), so converting it to a function is safe. The test that read the old constant now callsgetDefaultDateRange(), and a new test mocks the system clock across a year boundary (2030 then 2031) to confirm the range is computed lazily rather than captured once.Pillar
Visual Preview
Not applicable. Internal date-range utility change.
Checklist before requesting a review:
CONTRIBUTING.mdfile.utils/dateRange.test.tstests pass, 14 tests including the new lazy-evaluation test;tsc --noEmitclean for this file).npm run formatandnpm run lintlocally and resolved all errors (CI will fail otherwise).feat(themes): ...,fix(calculate): ...).README.mdif I added a new theme or URL parameter. (No new theme or URL parameter.)