pull down to refresh
111 sats \ 13 replies \ @0xbitcoiner 16 Oct \ on: Stacker Saloon
When there's a userId, does this query actually pull up anything? And is the creation date after now? Maybe I'm reading this wrong.
@chess
reply
Or, rather, is it related to the seed job only doing hats (like, after a restart)?
./worker/streak.js:export async function checkStreak ({ data: { id, type = 'COWBOY_HAT' }, models }) { ./docker/db/seed.sql: INSERT INTO pgboss.job (name, data, priority) VALUES ('checkStreak', jsonb_build_object('id', NEW.id), -1);
Or how msat reduction triggers it
./docker/db/seed.sql:CREATE TRIGGER user_streak AFTER UPDATE ON public.users FOR EACH ROW WHEN ((new.msats < old.msats)) EXECUTE FUNCTION public.user_streak_check(); INSERT INTO pgboss.job (name, data, priority) VALUES ('checkStreak', jsonb_build_object('id', NEW.id), -1);
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.
reply
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.
reply
~ $ sudo reboot
reply
just messing around with comment editing after 10 minutes
edit
: Comment edited 15 minutes after creation.reply
reply
yes!
To replicate the issue, try clicking 'edit' within the 10-minute window but don't confirm any changes during that time. I waited an extra 5 minutes after the 10-minute mark and it still recorded. I only discovered this by chance when I had to step away to use the bathroom mid-edit.
reply