Hacktoberfest / hacktoberfest-2020

Hacktoberfest - App to manage the annual open-source challenge, used for the 2019 & 2020 seasons.

Home Page:https://hacktoberfest.digitalocean.com

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

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:

  1. Complete four pull requests in October
  2. Remove GitHub authorization
  3. Wait until a few days after the contest ends
  4. 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:

  1. Cap waiting_since so that the maximum value is that of the END_DATE env var.
  2. Whenever a user moves to waiting, set waiting_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