feat(don): purge expired mobile upload sessions
This commit is contained in:
@@ -12,6 +12,7 @@ import {
|
||||
endgameSubmissions,
|
||||
endgameTypes,
|
||||
settings,
|
||||
slipSync,
|
||||
submissions,
|
||||
tierlistColumns,
|
||||
tierlistTiers,
|
||||
@@ -60,6 +61,20 @@ function logger(group: string) {
|
||||
return t;
|
||||
}
|
||||
|
||||
async function checkMobileSyncExpiration() {
|
||||
const { log, schedule } = logger("mobileSync");
|
||||
|
||||
const count = await db
|
||||
.delete(slipSync)
|
||||
.where(lt(slipSync.created, sql`NOW() - INTERVAL '1 hour'`))
|
||||
.returning({ id: slipSync.trackingKey });
|
||||
const removed = count.length;
|
||||
|
||||
if (removed) log("Purged", removed, "sessions");
|
||||
|
||||
schedule([], checkMobileSyncExpiration);
|
||||
}
|
||||
|
||||
async function checkRubgramExpiration() {
|
||||
const { log, schedule } = logger("rubgramExpiration");
|
||||
const { removed } = await removeExpiredSubmissions();
|
||||
@@ -326,6 +341,7 @@ const redisSubscribers: Record<
|
||||
};
|
||||
|
||||
checkRubgramExpiration();
|
||||
checkMobileSyncExpiration();
|
||||
seedDatabase();
|
||||
cacheCards();
|
||||
console.log("Tasks assigned");
|
||||
|
||||
@@ -374,6 +374,7 @@ export const slipSync = schDonate.table("sync", {
|
||||
trackingKey: text().primaryKey().$defaultFn(uuidv7).$type<TTrackingKey>(),
|
||||
accessKey: text().notNull().$defaultFn(uuidv7).$type<TAccessKey>(),
|
||||
uploadKey: text().notNull().$defaultFn(uuidv7).$type<TUploadKey>(),
|
||||
created: timestamp("created_at").defaultNow().notNull(),
|
||||
|
||||
data: bytea(),
|
||||
name: text(),
|
||||
|
||||
Reference in New Issue
Block a user