pull down to refresh
reply
Yes, it's not rolling but it checks every midnight Chicago time if the streak is still valid. This means you can gain a streak at any time but you can only lose it at midnight.
And anon gets an extra day?
No, this function is used in two different contexts. In the first context, it's called to check if a user has a new streak. We pass
userId
in that case and then we check for their zaps from today.In the other context, it's called without
userId
to check if streaks have been lost. This means we want to get zaps from all users from the previous day since remember, we run this function at midnight which basically means slightly after midnight. Therefore, we need - interval '1 day'
in that case.Could have been communicated better through the code but it works.
::date
at the end casts the current timestamp to a date so it's actually the current date that we're using, not the current timestamp in which case you would be right: