Repository navigation
I solved the streak issue(#918) - #943
aryansingh42046 wants to merge 1 commit into
Conversation
…ion calendars into getContributionDates() and then into the streak calculation. The problem was that contribution data from adjacent yearly calendars could overlap and remain in an incorrect order, so the algorithm sometimes processed dates out of sequence and incorrectly included days with zero contributions. I fixed this by sorting the merged contribution dates chronologically before calculating streaks, added a regression test in StatsTest.php using overlapping yearly calendars, and updated the FAQ to explain how the timezone option can be used for local-day calculations. The code passed static problem checks and git diff --check; PHPUnit could not be executed because PHP and Composer are unavailable in the environment.
|
Hi @aryansingh42046, thanks for working on this! I've also been running into a similar problem with my own streak card not matching my contribution graph, which is how I came across #918 and then this PR. I tried it out locally and wanted to share what I found, in case it helps. What worked well:
One thing I wasn't able to confirm:
Also, since #918 doesn't include a username or what the card shows versus what the contribution graph shows, it's hard to tell whether this is the cause. It might be worth asking the reporter for those details. Happy to be corrected on any of this. Thanks again for the contribution! |
|
Thanks for the thorough testing! You're right I appreciate you digging into the actual GitHub data to check whether overlapping yearly calendars happen in practice. Since you found that GitHub consistently returns Jan 1 → Dec 31 per year with no overlap, I'm reconsidering whether Looking at the other open issues (#890 , #933, #922), several users report timezone-related streak resets and incorrect contribution detection. Those seem more likely to be the root cause. I'm going to close this PR and investigate those issues instead they have clearer reproduction cases. But the FAQ addition about the timezone parameter is still useful, so I can submit that separately. Thanks again for the careful review! |
|
Thanks for the thoughtful reply, @aryansingh42046, and for taking another look at the data. That's the right call. The FAQ addition about the I'm fairly new to open source myself, so if you'd like to collaborate on this repo or anything else, feel free to reach out here or through my GitHub profile. |
This change fixes an issue in the streak calculation caused by contribution dates from adjacent yearly GitHub calendars being merged without guaranteed chronological ordering. When overlapping calendar data was processed out of order, the streak algorithm could incorrectly skip zero-contribution days and report an inflated streak.
The merged contribution dates are now sorted chronologically before streak statistics are calculated. A regression test was added to cover overlapping yearly calendars and verify that the current streak is calculated correctly. The FAQ was also updated to explain how the timezone option can be used to ensure current-day checks match the user’s local timezone.
Type of change
Bug fix (added a non-breaking change which fixes an issue)
New feature (added a non-breaking change which adds functionality)
Updated documentation (updated the readme, templates, or other repo files)
Breaking change (fix or feature that would cause existing functionality to work differently)
How Has This Been Tested?
Tested locally with a valid username
Tested locally with an invalid username
Ran tests with composer test — could not run because PHP and Composer are unavailable in the environment
Added or updated test cases to reproduce and prevent the issue
Static problem checks passed with no errors
git diff --check passed
Checklist:
The code is properly formatted and is consistent with the existing code style
I have commented my code, particularly in hard-to-understand areas
I have made corresponding changes to the documentation
My changes generate no new warning