Open-Assistant icon indicating copy to clipboard operation
Open-Assistant copied to clipboard

WIP: 906 update user streaks

Open melvinebenezer opened this issue 1 year ago • 1 comments

  1. Remove streak_last_day_date & streak_days from UserStats and add them to User (add a server default current_timestamp() for streak_last_day_date) + add a nullable additional last_activity_date datetimetz column to User.
  2. Update last_activity to the current time whenever the user sends a task results, e.g. after tm.handle_interaction() in the tasks_interaction endpoint.
  3. Store the process start time in a global variable.
  4. Add a new periodically executed function to main.py (similar to the stats updates) that runs every 4h and updates the streak value but for the first time not before the process ran for more than 24h (e.g. to gracefully recover from potential system outages, simply return if timedelta to procses-start time < 24h). Set the streak_days value to 0 of all users who have a last_activity_date older than 24 hours and streak_days > 0. Increments the streak value by 1 and set streak_last_day_date to the current time for all user's having current_time() - streak_last_day_date > 24 h.

Test Evidence: Screenshot 2023-01-30 at 8 20 57 PM

melvinebenezer avatar Jan 30 '23 14:01 melvinebenezer