fix(api): weekly pool window start landed on next Monday all day Sunday - #1039
Merged
Merged
Conversation
getWeeklyPoolWindowStart walked back to "Monday of this week" with now.AddDate(0, 0, -int(now.Weekday())+1). Go numbers Sunday as 0, so on Sundays that is +1 day: the *following* Monday 16:00 UTC. With the window start in the future no disbursement matched, and /v1/challenges/:id/info reported the full weekly pool as remaining every Sunday. TestV1ChallengesInfo failed the same way on Sundays, which is how this surfaced. Compute days-since-Monday with Sunday as 6, then step back a week when it is Monday before 16:00. The time.Now() read moves out into a thin wrapper so the function can be tested across the week. Also drops the stray fmt.Println of the window start on every request. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Why
getWeeklyPoolWindowStartwalks back to "Monday of this week" withnow.AddDate(0, 0, -int(now.Weekday())+1). Go numbers Sunday as 0, so on Sundays that is +1 day: the following Monday 16:00 UTC. With the window start in the future, no disbursement matches and/v1/challenges/:id/inforeports the full weekly pool as remaining every Sunday.TestV1ChallengesInfofails the same way on Sundays (it is failing onmaintoday, and blocked #1038's CI).What
time.Now()moves into a thin wrapper so the window function is testable; new table test covers Monday before/at 16:00, midweek, Saturday, and both ends of Sunday.fmt.Printlnof the window start that ran on every request.🤖 Generated with Claude Code