change how we select accounts

This commit is contained in:
Andre Medeiros 2021-07-07 18:47:59 -04:00
parent 9b73c74486
commit 827e61f3f9

View file

@ -64,7 +64,7 @@ func accountWorker(id int, rc *reddit.Client, db *sql.DB, logger *log.Logger, st
query := ` query := `
SELECT id, username, access_token, refresh_token, expires_at, last_message_id, last_checked_at FROM accounts SELECT id, username, access_token, refresh_token, expires_at, last_message_id, last_checked_at FROM accounts
WHERE last_checked_at <= $1::float - 5 WHERE last_checked_at + 5 <= $1::float
ORDER BY last_checked_at ORDER BY last_checked_at
LIMIT 1 LIMIT 1
FOR UPDATE SKIP LOCKED` FOR UPDATE SKIP LOCKED`