All checks were successful
Deploy production / deploy (push) Successful in 1m6s
31 lines
1.2 KiB
TypeScript
31 lines
1.2 KiB
TypeScript
// Games match history ingest (CS2 / PUBG / R6), the same pass the app runs every 20 minutes
|
|
// (src/lib/server/games/poller.ts). Use it for backfills and debugging, inside the app
|
|
// container so it has DB_URL and the keys:
|
|
// sudo docker exec personal-website-app-1 bun scripts/games-ingest.ts --backfill
|
|
// … bun scripts/games-ingest.ts --only leetify,faceit --force
|
|
import postgres from 'postgres';
|
|
import { runIngest } from '../src/lib/games-ingest/run';
|
|
|
|
const url = process.env.DB_URL;
|
|
if (!url) throw new Error('Set DB_URL');
|
|
const arg = (name: string) => {
|
|
const i = process.argv.indexOf(name);
|
|
return i >= 0 ? process.argv[i + 1] : undefined;
|
|
};
|
|
const sql = postgres(url, { max: 1, prepare: false, onnotice: () => {} });
|
|
try {
|
|
const results = await runIngest(sql, process.env, {
|
|
backfill: process.argv.includes('--backfill'),
|
|
force: process.argv.includes('--force'),
|
|
only: arg('--only')?.split(','),
|
|
log: (m) => console.error(m)
|
|
});
|
|
for (const r of results)
|
|
console.log(
|
|
`${r.status.padEnd(7)} ${r.game.padEnd(4)} ${r.source.padEnd(8)} ${r.account}: +${r.added}${r.note ? ` (${r.note})` : ''}`
|
|
);
|
|
if (results.some((r) => r.status === 'error')) process.exitCode = 1;
|
|
} finally {
|
|
await sql.end();
|
|
}
|