You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
13 lines
602 B
13 lines
602 B
import { getStats } from "../../service/scheduler";
|
|
import { getJobCount } from "../../scheduler/engine";
|
|
|
|
export default defineWrappedResponseHandler(async () => {
|
|
const cacheKey = 'scheduler:stats'
|
|
const cached = await event.context.cache.get<{ totalTasks: number, enabledTasks: number, last24hExecutions: number, activeJobs: number }>(cacheKey)
|
|
if (cached) return R.success({ ...cached, activeJobs: getJobCount() })
|
|
|
|
const stats = await getStats();
|
|
const result = { ...stats, activeJobs: getJobCount() }
|
|
await event.context.cache.set(cacheKey, result, 60)
|
|
return R.success(result);
|
|
});
|