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.
 
 
 
 

14 lines
637 B

import { getCache, setCache } from "#server/utils/context";
import { getStats } from "../../service/scheduler";
import { getJobCount } from "../../scheduler/engine";
export default defineWrappedResponseHandler(async (event) => {
const cacheKey = 'scheduler:stats'
const cached = await getCache<{ 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 setCache(cacheKey, result, 60)
return R.success(result);
});