Skip to content

Phase 2: maintenance tracking and alert engine#5

Merged
faborubio merged 1 commit into
mainfrom
phase-2-maintenance-alerts
Jun 12, 2026
Merged

Phase 2: maintenance tracking and alert engine#5
faborubio merged 1 commit into
mainfrom
phase-2-maintenance-alerts

Conversation

@faborubio

Copy link
Copy Markdown
Owner

Summary

Adds maintenance/compliance tracking and a proactive alert engine on top of the Phase 1 fleet core.

Data model

  • ServiceRecord — logged maintenance (category, date, odometer, cost, vendor).
  • MaintenanceSchedule — recurring rules per vehicle (every N months and/or N miles) that compute next_due_on / next_due_odometer.
  • Renewal — document expiry (insurance, registration, inspection).
  • Alert — polymorphic (alertable) with category, severity and status enums.

Alert engine

  • Alerts::Scanner reconciles an account's alerts idempotently: creates an alert when a condition holds, updates it in place when the underlying date changes, swaps due_soonexpired over time, and dismisses it once the condition clears. Covers overdue/expiring renewals, due maintenance (time or mileage), and expiring driver licenses.
  • Alerts::Dispatcher emails opted-in users a digest and marks pending alerts as sent so they aren't re-emailed.
  • ScanAllAlertsJob fans out one AccountAlertsJob per account; scheduled daily via Solid Queue recurring tasks (config/recurring.yml).

UI & notifications

  • Maintenance CRUD nested under vehicles, surfaced as sections on the vehicle page (renewals, schedules with due badges, service history).
  • Alerts index, a live nav badge, and Turbo Stream dismiss.
  • AlertsMailer digest (HTML + text) with a working mailer preview.
  • Logging a service auto-updates the matching schedule's last-performed markers.

Test plan

  • 129 RSpec examples green (models, scanner idempotency/reconciliation, dispatcher, mailer, jobs, request + system specs)
  • RuboCop, Brakeman, bundler-audit, importmap audit clean
  • db:seed now generates renewals, service history and ~55 open alerts for a lively demo
  • CI green on this PR

🤖 Generated with Claude Code

- ServiceRecord, MaintenanceSchedule, Renewal and a polymorphic Alert model
- Due-date logic: schedules track months/miles intervals and compute next-due;
  renewals and driver licenses track expiry with due-soon windows
- Logging a service auto-syncs the matching schedule's last-performed markers
- Alerts::Scanner reconciles an account's alerts idempotently (create / update
  in place / dismiss when cleared / swap due_soon->expired)
- Alerts::Dispatcher emails opted-in users a digest and marks alerts sent
- ScanAllAlertsJob fans out per-account AccountAlertsJob; scheduled daily via
  Solid Queue recurring tasks
- In-app: alerts index, live nav badge, Turbo Stream dismiss
- AlertsMailer digest (HTML + text) with a working mailer preview
- Maintenance CRUD nested under vehicles, surfaced on the vehicle page
- 129 specs green; demo seeds now generate renewals, service history and alerts

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@faborubio
faborubio merged commit c401b72 into main Jun 12, 2026
4 checks passed
@faborubio
faborubio deleted the phase-2-maintenance-alerts branch June 12, 2026 03:53
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.

1 participant