Waiting since calculation
johndbritton opened this issue · comments
Describe the bug
If a user enters the waiting
state after the end of Hacktoberfest, they are forced to wait the full seven days. This can lead to extra long waits when the user enters the waiting state a few days after the contest ends.
To Reproduce
Steps to reproduce the behavior:
- Complete four pull requests in October
- Remove GitHub authorization
- Wait until a few days after the contest ends
- Log in to Hacktoberfest again and reauthorize
Expected behavior
The user should not have to wait more than 7 days after the end of Hacktoberfest
Actual behavior
waiting_since
is set to the date a few days after the end of Hacktoberfest, meaning that the user has to wait 7 full days from the waiting since date resulting in a total of more than seven days since the end of Hacktoberfest.
Additional context
This issue impacted a small number of users in 2019, as a workaround, we manually set their waiting_since
value to a date before the end of Hacktoberfest based on the users last scoring pull request created at date.
There are two obvious solutions to this, in my mind:
- Cap
waiting_since
so that the maximum value is that of theEND_DATE
env var. - Whenever a user moves to
waiting
, setwaiting_since
based on their most recent PR, not the current time.
I personally think 2 is a better solution as it also solves other issues where users were confused that their timer didn't align with their last PR due to auth issues (that also cause this issue).
Here's a snippet to calculate according to number 2 as @MattIPv4 suggested:
waiting_since = scoring_pull_requests.max_by { |pr| pr.created_at }.created_at