mirror of
https://github.com/misenhower/splatoon3.ink.git
synced 2026-03-21 17:54:13 -05:00
Move X-Rank updaters into a separate, low-priority schedule
This commit is contained in:
parent
8b2cd71e5f
commit
3ffc71e5b1
|
|
@ -1,12 +1,15 @@
|
|||
import { CronJob } from "cron";
|
||||
import { updateAll } from "./data/index.mjs";
|
||||
import { updatePrimary, updateLowPriority } from "./data/index.mjs";
|
||||
import { warmCaches } from "./splatnet/index.mjs";
|
||||
import { sendStatuses } from "./social/index.mjs";
|
||||
|
||||
export default function() {
|
||||
new CronJob('5,20,35,50 * * * *', warmCaches, null, true);
|
||||
new CronJob('15 0,2,5,10,15,30,45 * * * *', async () => {
|
||||
await updateAll();
|
||||
await updatePrimary();
|
||||
await sendStatuses();
|
||||
}, null, true);
|
||||
new CronJob('1 * * * *', async () => {
|
||||
await updateLowPriority();
|
||||
}, null, true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,21 +16,43 @@ function updaters() {
|
|||
tokens.EU && new FestivalUpdater('EU'),
|
||||
tokens.JP && new FestivalUpdater('JP'),
|
||||
tokens.AP && new FestivalUpdater('AP'),
|
||||
new XRankUpdater('Tentatek', 'ATLANTIC'),
|
||||
new XRankUpdater('Takoroka', 'PACIFIC'),
|
||||
].filter(u => u);
|
||||
}
|
||||
|
||||
export async function updateAll() {
|
||||
console.info('Running all updaters...');
|
||||
function lowPriorityUpdaters() {
|
||||
return [
|
||||
new XRankUpdater('Tentatek', 'ATLANTIC'),
|
||||
new XRankUpdater('Takoroka', 'PACIFIC'),
|
||||
];
|
||||
}
|
||||
|
||||
for (let updater of updaters()) {
|
||||
async function run(updaters) {
|
||||
for (let updater of updaters) {
|
||||
try {
|
||||
await updater.updateIfNeeded();
|
||||
} catch (e) {
|
||||
console.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
console.info('Done running updaters');
|
||||
}
|
||||
|
||||
export async function updateAll() {
|
||||
console.info('Running all updaters...');
|
||||
await run([
|
||||
...updaters(),
|
||||
...lowPriorityUpdaters(),
|
||||
]);
|
||||
console.info('Done running all updaters');
|
||||
}
|
||||
|
||||
export async function updatePrimary() {
|
||||
console.info('Running primary updaters...');
|
||||
await run(updaters());
|
||||
console.info('Done running primary updaters');
|
||||
}
|
||||
|
||||
export async function updateLowPriority() {
|
||||
console.info('Running low-priority updaters...');
|
||||
await run(lowPriorityUpdaters());
|
||||
console.info('Done running low-priority updaters');
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import dotenv from 'dotenv';
|
|||
import consoleStamp from 'console-stamp';
|
||||
import cron from './cron.mjs';
|
||||
import { sendStatuses, testStatuses } from './social/index.mjs';
|
||||
import { updateAll } from './data/index.mjs';
|
||||
import { updatePrimary, updateAll } from './data/index.mjs';
|
||||
import { warmCaches } from "./splatnet/index.mjs";
|
||||
import MastodonClient from './social/clients/MastodonClient.mjs';
|
||||
import ImageWriter from './social/clients/ImageWriter.mjs';
|
||||
|
|
@ -16,7 +16,8 @@ const actions = {
|
|||
socialTest: testStatuses,
|
||||
socialTestMastodon: () => testStatuses([new MastodonClient]),
|
||||
socialTestImage: () => testStatuses([new ImageWriter]),
|
||||
splatnet: updateAll,
|
||||
splatnet: updatePrimary,
|
||||
splatnetAll: updateAll,
|
||||
warmCaches,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@
|
|||
"social:test:image": "node app/index.mjs socialTestImage",
|
||||
"social:test:mastodon": "node app/index.mjs socialTestMastodon",
|
||||
"splatnet": "node app/index.mjs splatnet",
|
||||
"splatnet:all": "node app/index.mjs splatnetAll",
|
||||
"warmCaches": "node app/index.mjs warmCaches"
|
||||
},
|
||||
"dependencies": {
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user