Files
ss-tools/specs/009-backup-scheduler/tasks.md
2025-12-30 21:30:37 +03:00

3.1 KiB

Tasks: Backup Scheduler & Unified Task UI

Phase 1: Setup

  • T001 Initialize SQLite database tasks.db and SQLAlchemy engine in backend/src/core/database.py
  • T002 Create SQLAlchemy model for TaskRecord in backend/src/models/task.py
  • T003 Update backend/src/core/config_models.py to include Schedule and update Environment model
  • T004 Create database migrations or initialization script for tasks.db

Phase 2: Foundational

  • T005 [P] Implement TaskPersistence layer in backend/src/core/task_manager/persistence.py
  • T006 Update TaskManager in backend/src/core/task_manager/manager.py to use persistence for all jobs
  • T007 Implement SchedulerService using APScheduler in backend/src/core/scheduler.py
  • T008 Integrate SchedulerService into main FastAPI application startup in backend/src/app.py

Phase 3: [US1] Scheduled Backups

  • T009 [US1] Implement schedule loading and registration logic in SchedulerService
  • T010 [US1] Update Environment settings API to handle backup_schedule updates in backend/src/api/routes/environments.py
  • T011 [P] [US1] Add schedule configuration fields to Environment edit form in frontend/src/components/EnvSelector.svelte (or appropriate component)
  • T012 [US1] Implement validation for Cron expressions in backend and frontend

Phase 4: [US2] Unified Task Management UI

  • T013 [US2] Implement /api/tasks endpoint to list and filter tasks in backend/src/api/routes/tasks.py
  • T014 [US2] Create new Tasks page in frontend/src/routes/tasks/+page.svelte
  • T015 [P] [US2] Implement TaskList component in frontend/src/components/TaskList.svelte
  • T016 [US2] Add "Tasks" link to main navigation in frontend/src/components/Navbar.svelte

Phase 5: [US3] Manual Backup Trigger

  • T017 [US3] Implement /api/tasks/backup POST endpoint in backend/src/api/routes/tasks.py
  • T018 [US3] Add "Run Backup" button and environment selection to Tasks page in frontend/src/routes/tasks/+page.svelte

Phase 6: [US4] Task History & Logs

  • T019 [US4] Implement /api/tasks/{task_id} GET endpoint for detailed task info and logs in backend/src/api/routes/tasks.py
  • T020 [US4] Implement TaskLogViewer component in frontend/src/components/TaskLogViewer.svelte
  • T021 [US4] Integrate log viewer into TaskList or as a separate modal/page

Final Phase: Polish & Cross-cutting concerns

  • T022 Implement task cleanup/retention policy (e.g., delete tasks older than 30 days)
  • T023 Add real-time updates for task status using WebSockets (optional/refinement)
  • T024 Ensure consistent error handling and logging across scheduler and task manager

Dependencies

  • US1 depends on Phase 1 & 2
  • US2 depends on Phase 1 & 2
  • US3 depends on US2
  • US4 depends on US2

Implementation Strategy

  1. Infrastructure First: Setup database and basic task persistence.
  2. Backend Logic: Implement scheduler and update task manager.
  3. API & UI: Build the unified tasks view.
  4. Feature Integration: Add scheduling UI and manual triggers.