Skip to content

Add cron statistics panel for script observability#2989

Draft
Copilot wants to merge 3 commits into
developfrom
copilot/add-statistics-panel
Draft

Add cron statistics panel for script observability#2989
Copilot wants to merge 3 commits into
developfrom
copilot/add-statistics-panel

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Apr 25, 2026

No way to get a high-level view of script execution health across many tasks — no totals, no trends, no outliers.

Backend

  • back/data/cronLog.ts — New CronLog Sequelize model (SQLite) storing per-execution records: cron_id, cron_name, start_time (Unix seconds), duration (seconds), indexed on both columns
  • back/loaders/db.ts — Syncs CronLog table on startup
  • back/services/cron.ts — Hooks into status() to persist a CronLog entry whenever a job transitions to idle with last_running_time > 0
  • back/services/cronStats.ts — Statistics service with:
    • stats() — task totals (all/enabled/disabled) + today's execution count and avg duration
    • trend() — per-day execution counts for the last 7 days
    • topDuration(5) / topCount(5) — today's slowest and most-frequent tasks with avg/max duration
  • back/api/cron.ts — Four new read-only endpoints:
    • GET /crons/stats
    • GET /crons/stats/trend
    • GET /crons/stats/top-duration
    • GET /crons/stats/top-count

Frontend

  • src/pages/statistics/index.tsx — New page composed of four modules:
    • Overview stat cards (total/enabled/disabled, today's runs, avg duration)
    • 7-day execution trend — pure SVG line chart, zero new dependencies
    • Top 5 by average duration (avg + max)
    • Top 5 by execution count (count + avg duration)
  • Sidebar nav entry, document title mapping, and zh-CN / en-US i18n keys added

Notes

Execution success/failure is not tracked yet — the current shell update_cron call does not propagate an exit code. The schema and service are structured to accommodate that extension without breaking changes.

@vercel
Copy link
Copy Markdown

vercel Bot commented Apr 25, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
qinglong Ready Ready Preview, Comment Apr 25, 2026 7:04am
qinglong-back Ready Ready Preview, Comment Apr 25, 2026 7:04am

Copilot AI changed the title [WIP] Add script observation statistics panel Add cron statistics panel for script observability Apr 25, 2026
Copilot AI requested a review from whyour April 25, 2026 06:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

📊 新增脚本统计面板 — 脚本可观测与运行状态总览

2 participants