Skip to content

armgit / Cap

Public Imported from GitHub
0

Open source Loom alternative. Beautiful, shareable screen recordings.

fix: use database clock for recovery window

Richie McIlroyd917b9a2c104
diff --git a/apps/web/lib/desktop-segments-recovery.ts b/apps/web/lib/desktop-segments-recovery.ts
index 5b8ab8fe2..a3ca90d47 100644
--- a/apps/web/lib/desktop-segments-recovery.ts
+++ b/apps/web/lib/desktop-segments-recovery.ts
@@ -29,7 +29,6 @@ import { decodeStorageVideo } from "@/lib/video-storage";
import { WORKFLOW_UPGRADE_ERROR_FRAGMENT } from "@/lib/workflow-recovery";
const MINUTE = 60 * 1000;
-const DAY = 24 * 60 * MINUTE;
export const DESKTOP_SEGMENTS_RECOVERY_MIN_AGE_MS = 60 * MINUTE;
export const DESKTOP_SEGMENTS_RECOVERY_STABILITY_MS = 15 * MINUTE;
@@ -399,7 +398,6 @@ export async function recoverStaleDesktopSegments({
const staleBefore = new Date(
now.getTime() - DESKTOP_SEGMENTS_RECOVERY_MIN_AGE_MS,
);
- const priorityWindowStart = new Date(now.getTime() - DAY);
const candidates = await db()
.select({
videoId: videos.id,
@@ -427,7 +425,7 @@ export async function recoverStaleDesktopSegments({
sql<number>`CASE WHEN ${videoUploads.processingError} LIKE ${`%${WORKFLOW_UPGRADE_ERROR_FRAGMENT}%`} THEN 1 ELSE 0 END`,
),
desc(
- sql<number>`CASE WHEN ${videoUploads.startedAt} >= ${priorityWindowStart} THEN 1 ELSE 0 END`,
+ sql<number>`CASE WHEN ${videoUploads.startedAt} >= UTC_TIMESTAMP() - INTERVAL 24 HOUR THEN 1 ELSE 0 END`,
),
asc(videoUploads.updatedAt),
)