gistfile1.txt
· 780 B · Text
Raw
resetWeek(): void {
// Fire the weekly reset on Monday 00:00 (WRank reset) (UTC+2 = Sunday 22:00)
const nowUtcNoon = new Date();
nowUtcNoon.setUTCHours(12, 0, 0, 0);
const newWeekKey = WRank.weekKey(nowUtcNoon);
const prevWeekKey = WRank.weekKey(new Date(nowUtcNoon.getTime() - 7 * 24 * 60 * 60 * 1000));
const prevWeek = _data[prevWeekKey];
const newWeek = ensureWeek(newWeekKey);
if (prevWeek) {
Bringer.update({ week: prevWeek });
for (const nation of [Nation.Capella, Nation.Procyon]) {
const bringer = prevWeek.bringer[nation];
if (bringer) newWeek.bringer[nation] = bringer;
}
}
WRank.save();
log.info(`Week reset to ${newWeekKey}. Bringer: ${JSON.stringify(newWeek.bringer)}`);
},
| 1 | resetWeek(): void { |
| 2 | // Fire the weekly reset on Monday 00:00 (WRank reset) (UTC+2 = Sunday 22:00) |
| 3 | const nowUtcNoon = new Date(); |
| 4 | nowUtcNoon.setUTCHours(12, 0, 0, 0); |
| 5 | |
| 6 | const newWeekKey = WRank.weekKey(nowUtcNoon); |
| 7 | const prevWeekKey = WRank.weekKey(new Date(nowUtcNoon.getTime() - 7 * 24 * 60 * 60 * 1000)); |
| 8 | const prevWeek = _data[prevWeekKey]; |
| 9 | const newWeek = ensureWeek(newWeekKey); |
| 10 | |
| 11 | if (prevWeek) { |
| 12 | Bringer.update({ week: prevWeek }); |
| 13 | for (const nation of [Nation.Capella, Nation.Procyon]) { |
| 14 | const bringer = prevWeek.bringer[nation]; |
| 15 | if (bringer) newWeek.bringer[nation] = bringer; |
| 16 | } |
| 17 | } |
| 18 | |
| 19 | WRank.save(); |
| 20 | log.info(`Week reset to ${newWeekKey}. Bringer: ${JSON.stringify(newWeek.bringer)}`); |
| 21 | }, |