29 lines
723 B
TypeScript
29 lines
723 B
TypeScript
import { cronJobs, makeFunctionReference } from "convex/server";
|
|
|
|
const reconcileGitConnectionsRef = makeFunctionReference<
|
|
"action",
|
|
Record<string, never>,
|
|
{ checked: number }
|
|
>("gitConnectionHealth:reconcileStaleConnections");
|
|
const backfillConnectionsRef = makeFunctionReference<
|
|
"mutation",
|
|
Record<string, never>,
|
|
{ migrated: number }
|
|
>("gitConnectionData:backfillConnections");
|
|
|
|
const crons = cronJobs();
|
|
|
|
crons.cron(
|
|
"reconcile stale git connections",
|
|
"0 * * * *",
|
|
reconcileGitConnectionsRef
|
|
);
|
|
// Backfill legacy connections on startup and every 6 hours until all are migrated.
|
|
crons.interval(
|
|
"backfill legacy git connections",
|
|
{ hours: 6 },
|
|
backfillConnectionsRef
|
|
);
|
|
|
|
export default crons;
|