feat(rubgram): change archive strategy to monthly incremental
This commit is contained in:
+25
-3
@@ -1,9 +1,9 @@
|
||||
import { env } from "node:process";
|
||||
import { redis } from "bun";
|
||||
import { cron, redis } from "bun";
|
||||
import { formatDistanceToNow } from "date-fns";
|
||||
import { and, asc, eq, gt, isNull, lt, not, sql } from "drizzle-orm";
|
||||
import { removeExpiredSubmissions } from "@/app/(ui)/rubgram/api";
|
||||
import { auth } from "@/lib/auth";
|
||||
import { archive, removeExpiredSubmissions } from "@/app/(ui)/rubgram/api";
|
||||
import { auth, issueInternalToken } from "@/lib/auth";
|
||||
import { db } from "@/lib/db";
|
||||
import {
|
||||
artifactSettings,
|
||||
@@ -272,6 +272,28 @@ async function cacheCards() {
|
||||
} else schedule(120, cacheCards);
|
||||
}
|
||||
|
||||
cron("0 0 1 * *", async function rubgramArchive() {
|
||||
const { log } = logger("rubgramArchive");
|
||||
log("Started...");
|
||||
await archive({});
|
||||
log("Done");
|
||||
});
|
||||
|
||||
cron("0 0 /14 * *", async function syncAmber() {
|
||||
const { log, error } = logger("syncAmber");
|
||||
log("Syncing...");
|
||||
const token = await issueInternalToken();
|
||||
const res = await fetch(`http://app:3000/api/amber/sync`, {
|
||||
headers: {
|
||||
"X-Internal-Auth": token,
|
||||
},
|
||||
}).catch(() => ({
|
||||
ok: false,
|
||||
}));
|
||||
if (res.ok) log("Success!");
|
||||
else error("Sync failed.");
|
||||
});
|
||||
|
||||
const redisSubscribers: Record<
|
||||
string,
|
||||
(payload: { data: unknown; event?: string }) => void
|
||||
|
||||
Reference in New Issue
Block a user