perf: stream slow load functions in admin pages to unblock navigation
- image-gen, text-gen: books list streamed (listBooks is expensive on cold cache) - ai-jobs: jobs list streamed; add 30s cache to listAIJobs (was uncached listAll) - changelog: Gitea releases streamed on cold cache; cached path stays synchronous - admin/+layout.svelte: remove duplicate audio/translation/image-gen nav links
This commit is contained in:
@@ -2287,10 +2287,17 @@ export async function getUserStats(
|
||||
|
||||
// ─── AI Jobs ──────────────────────────────────────────────────────────────────
|
||||
|
||||
const AI_JOBS_CACHE_KEY = 'admin:ai_jobs';
|
||||
const AI_JOBS_CACHE_TTL = 30; // 30 seconds — same as other admin job lists
|
||||
|
||||
/**
|
||||
* List all AI jobs from PocketBase, sorted by started descending.
|
||||
* No caching — admin views always want fresh data.
|
||||
* Short-lived cache (30s) to avoid hammering PocketBase on every navigation.
|
||||
*/
|
||||
export async function listAIJobs(): Promise<AIJob[]> {
|
||||
return listAll<AIJob>('ai_jobs', '', '-started');
|
||||
const cached = await cache.get<AIJob[]>(AI_JOBS_CACHE_KEY);
|
||||
if (cached) return cached;
|
||||
const jobs = await listAll<AIJob>('ai_jobs', '', '-started');
|
||||
await cache.set(AI_JOBS_CACHE_KEY, jobs, AI_JOBS_CACHE_TTL);
|
||||
return jobs;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user