feat(don): purge expired mobile upload sessions
Build and Push Image / build-backend (push) Successful in 1m5s
Build and Push Image / build-frontend (push) Successful in 2m42s
Build and Push Image / push (push) Successful in 1m23s

This commit is contained in:
2026-08-29 21:45:45 +07:00 Unverified
parent cba9bf4e8d
commit b2c0849a54
2 changed files with 17 additions and 0 deletions
+16
View File
@@ -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");
+1
View File
@@ -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(),