Skip to content

feat: open aoc days 1 day before reveal and show a countdown - #155

Merged
hmd-ali merged 1 commit into
mainfrom
feat/aoc-open-days-1-day-before
Dec 1, 2026
Merged

hmd-ali merged 1 commit into
mainfrom
feat/aoc-open-days-1-day-before

Conversation

@hmd-ali

@hmd-ali hmd-ali commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

No description provided.

@wiktoriavh

Copy link
Copy Markdown
Member

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
getAdventPostAction now returns 'reveal' for any open day whose post exists:

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 hmd-ali left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@hmd-ali

hmd-ali commented Dec 1, 2026

Copy link
Copy Markdown
Contributor Author
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)

@hmd-ali
hmd-ali merged commit fdc6c79 into main Dec 1, 2026
3 checks passed
@hmd-ali
hmd-ali deleted the feat/aoc-open-days-1-day-before branch December 1, 2026 19:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants