perf: cache admin job lists + targeted polling for audio/translation pages
Some checks failed
Release / Test backend (push) Successful in 41s
Release / Check ui (push) Failing after 34s
Release / Upload source maps (push) Has been skipped
Release / Docker / ui (push) Has been skipped
Release / Docker / caddy (push) Successful in 40s
Release / Docker / runner (push) Has been cancelled
Release / Gitea Release (push) Has been cancelled
Release / Docker / backend (push) Has been cancelled
Some checks failed
Release / Test backend (push) Successful in 41s
Release / Check ui (push) Failing after 34s
Release / Upload source maps (push) Has been skipped
Release / Docker / ui (push) Has been skipped
Release / Docker / caddy (push) Successful in 40s
Release / Docker / runner (push) Has been cancelled
Release / Gitea Release (push) Has been cancelled
Release / Docker / backend (push) Has been cancelled
- Add 30s Valkey cache to listScrapingTasks, listAudioJobs, listTranslationJobs (use listN(500) instead of unbounded listAll to cap at one request) - Delete listAudioCache() — derive AudioCacheEntry[] from jobs in server load - Add listBookSlugs() with 10min cache — replaces full listBooks() in translation load - Add GET /api/admin/audio-jobs, /api/admin/translation-jobs, /api/admin/scrape-tasks (lightweight polling endpoints backed by the Valkey cache) - Replace invalidateAll() interval polling in audio+translation pages with targeted fetch to the new endpoints (avoids re-running full server load)
This commit is contained in:
16
ui/src/routes/api/admin/audio-jobs/+server.ts
Normal file
16
ui/src/routes/api/admin/audio-jobs/+server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { listAudioJobs } from '$lib/server/pocketbase';
|
||||
|
||||
/**
|
||||
* GET /api/admin/audio-jobs
|
||||
* Returns the current audio jobs list (served from 30 s Valkey cache).
|
||||
* Used by the admin audio page for lightweight polling instead of invalidateAll().
|
||||
*/
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
if (!locals.user || locals.user.role !== 'admin') {
|
||||
throw error(403, 'Forbidden');
|
||||
}
|
||||
const jobs = await listAudioJobs().catch(() => []);
|
||||
return json({ jobs });
|
||||
};
|
||||
16
ui/src/routes/api/admin/scrape-tasks/+server.ts
Normal file
16
ui/src/routes/api/admin/scrape-tasks/+server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { listScrapingTasks } from '$lib/server/pocketbase';
|
||||
|
||||
/**
|
||||
* GET /api/admin/scrape-tasks
|
||||
* Returns the current scraping task list (served from 30 s Valkey cache).
|
||||
* Used by the admin scrape page for lightweight polling instead of invalidateAll().
|
||||
*/
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
if (!locals.user || locals.user.role !== 'admin') {
|
||||
throw error(403, 'Forbidden');
|
||||
}
|
||||
const tasks = await listScrapingTasks().catch(() => []);
|
||||
return json({ tasks });
|
||||
};
|
||||
16
ui/src/routes/api/admin/translation-jobs/+server.ts
Normal file
16
ui/src/routes/api/admin/translation-jobs/+server.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { json, error } from '@sveltejs/kit';
|
||||
import type { RequestHandler } from './$types';
|
||||
import { listTranslationJobs } from '$lib/server/pocketbase';
|
||||
|
||||
/**
|
||||
* GET /api/admin/translation-jobs
|
||||
* Returns the current translation jobs list (served from 30 s Valkey cache).
|
||||
* Used by the admin translation page for lightweight polling instead of invalidateAll().
|
||||
*/
|
||||
export const GET: RequestHandler = async ({ locals }) => {
|
||||
if (!locals.user || locals.user.role !== 'admin') {
|
||||
throw error(403, 'Forbidden');
|
||||
}
|
||||
const jobs = await listTranslationJobs().catch(() => []);
|
||||
return json({ jobs });
|
||||
};
|
||||
Reference in New Issue
Block a user