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
607 B

import { getStats } from "../../service/scheduler";
import { getJobCount } from "../../scheduler/engine";
export default defineWrappedResponseHandler(async (event) => {
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);
});