pull down to refresh

The ::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:
stackernews=# SELECT (now() AT TIME ZONE 'America/Chicago')::date; timezone ------------ 2024-10-17 (1 row)
So the query pulls all invoices that were created today.
So it's not a rolling 24h window, but resets on midnight Chicago time? And anon gets an extra day?
reply
33 sats \ 2 replies \ @ek 17 Oct
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.
reply
Thank you for the explanation!
reply
28 sats \ 0 replies \ @ek 17 Oct
No worries, glad people are interested in the code
reply