INNER CODE UNIT · TypeScript
cutoff
ekzhang/setwithfriends · functions/src/index.ts:511
const cutoff = Date.now() - 14 * 86400 * 1000; // 14 days ago
const queue = new PQueue({ concurrency: 200 });
const snap = await getDatabase()
.ref("gameData")
.orderByChild("populatedAt")
.endBefore(cutoff)
.get();
const childKeys: string[] = [];
snap.forEach((child) => {
childKeys.push(child.key);
});
let archiveCount = 0;
for (const gameId of childKeys) {
const gameState = snap.child(gameId);
const populatedAt: number | null = gameState.child("populatedAt").val();