dont reset all past streak when current streak ends

This commit is contained in:
keyan 2023-02-14 09:24:31 -06:00
parent f258d6da1c
commit 558419ffb3
1 changed files with 2 additions and 2 deletions

View File

@ -21,7 +21,7 @@ function computeStreaks ({ models }) {
WHERE (created_at AT TIME ZONE 'UTC' AT TIME ZONE 'America/Chicago')::date >= (now() AT TIME ZONE 'America/Chicago' - interval '1 day')::date
)) spending
GROUP BY "userId"
HAVING sum(sats_spent) >= ${STREAK_THRESHOLD}
HAVING sum(sats_spent) >= 100
), existing_streaks (id, started_at) AS (
SELECT "userId", "startedAt"
FROM "Streak"
@ -58,7 +58,7 @@ function computeStreaks ({ models }) {
UPDATE "Streak"
SET "endedAt" = (now() AT TIME ZONE 'America/Chicago' - interval '1 day')::date, updated_at = now_utc()
FROM ending_streaks
WHERE ending_streaks.id = "Streak"."userId"`)
WHERE ending_streaks.id = "Streak"."userId" AND "endedAt" IS NULL`)
console.log('done computing streaks')
}