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); });