From fcb28e8c749c10b8efd07d12076d4fb06e29cd09 Mon Sep 17 00:00:00 2001 From: sebastjanartic <45803536-sebastjanartic@users.noreply.replit.com> Date: Thu, 4 Sep 2025 06:35:54 +0000 Subject: [PATCH] Improve video data fetching by prioritizing cached information Refactor server-side video retrieval logic to first check local cache via `videoSyncService.getVideos` and `videoSyncService.getVideo`, falling back to `bunnyService.getVideo` only if cache misses. This change removes database merging logic from `videoSyncService` and integrates it into `BunnyStorage` when retrieving individual videos, optimizing data access. Replit-Commit-Author: Agent Replit-Commit-Session-Id: 2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1 Replit-Commit-Checkpoint-Type: full_checkpoint Replit-Commit-Screenshot-Url: https://storage.googleapis.com/screenshot-production-us-central1/8cc42625-c1f5-4e43-99bd-77f2c4dedee2/2cd2c0bc-434c-4bc9-ad3f-b99d3897a0d1/DVlzRoR --- .replit | 2 +- server/storage.ts | 40 ++++++++++++++++++++++++++++----------- server/videoSync.ts | 46 +++++---------------------------------------- 3 files changed, 35 insertions(+), 53 deletions(-) diff --git a/.replit b/.replit index 9eb5d4c..2d8a3dc 100644 --- a/.replit +++ b/.replit @@ -40,4 +40,4 @@ args = "npm run dev" waitForPort = 5000 [agent] -integrations = ["javascript_google_analytics==1.0.0", "javascript_database==1.0.0"] +integrations = ["javascript_database==1.0.0", "javascript_google_analytics==1.0.0"] diff --git a/server/storage.ts b/server/storage.ts index c8b1303..c272fca 100644 --- a/server/storage.ts +++ b/server/storage.ts @@ -797,7 +797,7 @@ class BunnyStorage implements IStorage { async getVideos(limit = 20, offset = 0, search?: string): Promise { console.log(`Fetching videos from cache: limit=${limit}, offset=${offset}, search=${search}`); - const result = await videoSyncService.getVideos(limit, offset, search); + const result = videoSyncService.getVideos(limit, offset, search); console.log(`Returning ${result.videos.length} videos from cache (age: ${result.cacheAge}ms)`); // Apply face detection data from cache @@ -808,18 +808,36 @@ class BunnyStorage implements IStorage { } async getVideo(id: string): Promise