Skip to content

Feature: Scheduled Maintenance (Auto-creating issues) #858

@timothyfroehlich

Description

@timothyfroehlich

Add support for recurring maintenance tasks that automatically create issues for machines on a schedule (e.g., 'Clean playfield' every month).

Requirements

  • Recurring Schedules: Admins should be able to define maintenance tasks that repeat at set intervals (days, weeks, months).
  • Auto-Issue Creation: The system should automatically generate a new issue when a schedule is due.
  • Admin UI: A management interface for admins to create, edit, pause, or delete maintenance schedules.
  • Traceability: Link auto-generated issues back to their schedule for history tracking.

Proposed Data Model

New table: maintenance_schedules

  • id: UUID (PK)
  • machine_initials: Text (FK to machines)
  • title: Text (Issue title)
  • description: Text (Issue description)
  • interval_type: Enum ('days', 'weeks', 'months')
  • interval_value: Integer
  • next_run_at: Timestamp
  • last_run_at: Timestamp
  • is_active: Boolean
  • severity: Enum (defaults to 'minor')
  • priority: Enum (defaults to 'low')

Technical Implementation

  1. Database: Add maintenance_schedules table via Drizzle migration.
  2. Scheduling Engine:
    • Option 1 (Recommended): Use Vercel Cron Jobs to hit a secure internal API route (/api/cron/maintenance) daily.
    • Option 2: Use Supabase pg_cron to run a stored procedure.
    • Using Vercel Cron allows us to reuse the existing createIssue logic in src/services/issues.ts, including all timeline and notification side-effects.
  3. Service Logic: Create a new service (src/services/maintenance.ts) to handle checking due schedules and triggering issue creation.

Relevant Files

  • src/server/db/schema.ts: Define the new table.
  • src/services/issues.ts: Reuse for issue creation.
  • src/app/(app)/admin/maintenance/page.tsx: New admin UI page.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions