Files
kevin-asprec 5cab1938b1 feat(phase-4): SMS gateway dashboard + stats + health + retry
Backend (backend/app/routers/sms.py):
- GET /api/sms/stats: aggregate totals by status, daily volume chart
  (configurable N days), per-school top-10 breakdown, delivery rate,
  live queue depth
- POST /api/sms/jobs/{id}/retry: reset failed/cancelled job to pending
- GET /api/sms/health: Semaphore API connectivity check + credit balance
- POST /api/sms/trigger-queue: manually fire sms.process_queue Celery task

Frontend (frontend/src/pages/SmsPage.vue) — rebuilt from scratch:
- Semaphore health badge with live status indicator and balance display
- 'Process Queue' button calling POST /api/sms/trigger-queue
- KPI row: Total, Sent, Failed, Pending (queue depth), Delivery Rate %;
  period picker switching between 7/30/90 day views
- Volume bar chart: daily sent vs failed bars with hover tooltips,
  x-axis date labels, legend; no charting library required
- School breakdown panel: top 10 schools by volume with delivery
  percentage bars
- Jobs table: status + school + phone number filters; inline error
  message on failed rows; Retry button for failed/cancelled jobs;
  retry count display; pagination

api.ts: getSmsStats, retrySmsJob, getSmsHealth, triggerSmsQueue

PAUL: Phase 4 marked complete, STATE + ROADMAP updated
2026-03-16 10:37:23 +08:00

26 lines
1.1 KiB
Markdown

# Phase 04: SMS Gateway (Credits + Queue)
**Status:** ✅ Complete — 2026-03-15
## Goal
Schools submit SMS jobs via Hub; Hub sends via Semaphore; credits deducted per message.
Full SMS dashboard for super admin with stats, charts, job table, Semaphore health.
## Completed
### 4-01: Backend stats + retry + health + trigger
- `GET /api/sms/stats` — aggregate totals, daily chart (N days), school breakdown
- `POST /api/sms/jobs/{id}/retry` — reset failed/cancelled job to pending
- `GET /api/sms/health` — Semaphore connectivity + credit balance
- `POST /api/sms/trigger-queue` — manual Celery task trigger (admin)
- `api.ts`: getSmsStats, retrySmsJob, getSmsHealth, triggerSmsQueue
### 4-02: SmsPage full dashboard
- Semaphore health badge (green/red, shows balance)
- Process Queue button (fires trigger-queue)
- KPI row: Total, Sent, Failed, Pending, Delivery Rate %, period picker 7/30/90d
- Volume bar chart (daily sent vs failed, hover tooltips)
- School breakdown panel (top 10, sent/total ratio bars)
- Jobs table: status + school + phone filters, error message on failed rows,
Retry button, retry count, pagination