Skip to content

Commit 014be19

Browse files
committed
refactor: remove redundant comments and improve clarity in Advent scheduler
1 parent f22a94d commit 014be19

File tree

1 file changed

+2
-9
lines changed

1 file changed

+2
-9
lines changed

src/util/advent-scheduler.ts

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,6 @@ async function createAdventPost(
8282
}
8383
}
8484

85-
/**
86-
* Check if today is during Advent of Code (December 1-25) and create post if needed
87-
*/
8885
async function checkAndCreateTodaysPost(client: Client, channelId: string): Promise<void> {
8986
const now = new Date();
9087
const month = now.getUTCMonth(); // 0-indexed, so December is 11
@@ -101,17 +98,14 @@ async function checkAndCreateTodaysPost(client: Client, channelId: string): Prom
10198
return;
10299
}
103100

104-
// Check if we've already posted for this day this year
105101
const alreadyPosted = await isDayPosted(year, day);
106102
if (alreadyPosted) {
107103
console.log(`ℹ️ Advent of Code post for ${year} day ${day} already exists`);
108104
return;
109105
}
110106

111-
// Create the post
112107
const success = await createAdventPost(client, channelId, year, day);
113108

114-
// Mark as posted if successful
115109
if (success) {
116110
await markDayAsPosted(year, day);
117111
}
@@ -124,13 +118,12 @@ async function checkAndCreateTodaysPost(client: Client, channelId: string): Prom
124118
export function initializeAdventScheduler(client: Client, channelId: string): void {
125119
console.log('🎄 Initializing Advent of Code scheduler...');
126120

127-
// Run immediately on startup to check if we need to post today
128121
checkAndCreateTodaysPost(client, channelId).catch((error) => {
129122
console.error('❌ Error checking for Advent of Code post on startup:', error);
130123
});
131124

132-
// Schedule to run every day at midnight UTC
133-
// Cron pattern: '0 5 * * *' = At 05:00 UTC every day (midnight UTC-5)
125+
// Schedule to run every day at midnight UTC-5
126+
// https://github.com/node-cron/node-cron?tab=readme-ov-file#cron-syntax
134127
cron.schedule('0 5 * * *', () => {
135128
console.log('⏰ Running scheduled Advent of Code check...');
136129
checkAndCreateTodaysPost(client, channelId).catch((error) => {

0 commit comments

Comments
 (0)