Repository navigation
feat: open aoc days 1 day before reveal and show a countdown - #155
Conversation
|
It looked fine to me, then I also let AI review it and it revealed something I didn't catch. It might be worth to store the reveal in the database so that we only do the check on the required non-revealed posts instead of all of them. Main concern: repeated re-reveals on every scheduler run return step.phase === 'open' ? 'reveal' : 'none';Combined with getAdventPostSteps returning all open days 1..N, every scheduler run re-edits every already-open post. On Dec 12's run that's 11 revealPost edits, and it repeats on every subsequent run until Dec 13. If the scheduler only fires once at midnight EST this is mostly wasted API calls, but if it runs more often (or is restarted/redeployed mid-day, which triggers runScheduledAdventPostCheck again) you get edit spam. Consider persisting a revealedAt/revealed flag in the Prisma record, or having revealPost short-circuit when the message already shows the link. (The old code had a milder version of this for day 1 only, so it's pre-existing, but this PR multiplies it.) |
hmd-ali
left a comment
There was a problem hiding this comment.
Each run only compares content before editing, edits happens only when the content differs.
On Dec 12, day 12 opens, 1 edit. Days 1-11 already revealed the links, so no edits.
Same thing for Restarts, threads are only read (to make sure they match their states), and there's no edits unless there's a mismatch.
const content = getPostContent(step); // gets the correct message that should be displayed by the bot, based on the date. (either a countdown, or the link to the aoc day)
if (starterMessage.content === content) { // if the current message in the thread matches, return early
return;
}
await starterMessage.edit({ content }); // edits only when it doesn't match.(at midnight, when the phase changed) |
No description provided.