Skip to content

Commit

Permalink
🐛 fix multi-scheduling (#109)
Browse files Browse the repository at this point in the history
  • Loading branch information
dudeofawesome authored Feb 8, 2023
1 parent d64a178 commit 4ea4a28
Showing 1 changed file with 5 additions and 8 deletions.
13 changes: 5 additions & 8 deletions src/scheduling/scheduling.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,14 +44,12 @@ export class SchedulingService implements OnApplicationBootstrap {
.filter((guild) => guild.score.reset_enabled)
.reduce((schedules, guild) => {
// TODO: get timezone from guild?
if (
schedules.get([guild.score.reset_schedule, 'UTC'])?.push(guild.id) ==
null
) {
schedules.set([guild.score.reset_schedule, 'UTC'], [guild.id]);
const key = `${guild.score.reset_schedule}\n${'UTC'}`;
if (schedules.get(key)?.push(guild.id) == null) {
schedules.set(key, [guild.id]);
}
return schedules;
}, new Map<[string, string], string[]>());
}, new Map<string, string[]>());

// clear scheduled jobs
this.scheduler
Expand All @@ -60,8 +58,7 @@ export class SchedulingService implements OnApplicationBootstrap {

// rebuild scheduled jobs
for (const [schedule, guild_ids] of schedules) {
const expr = schedule[0];
const tz = schedule[1];
const [expr, tz] = schedule.split('\n');
try {
this.scheduler.addCronJob(
`guild_reset ${schedule}`,
Expand Down

0 comments on commit 4ea4a28

Please sign in to comment.