# Implementation Plan - [x] 1. Database Schema and Index Optimization - Create database indexes to optimize task status queries for shots and assets - Add composite indexes for common query patterns (shot_id + status, asset_id + status) - Test index performance with sample data - _Requirements: 3.1, 3.2_ - [ ]* 1.1 Write property test for database index performance - **Property 7: Scalable Query Performance** - **Validates: Requirements 3.2** - [x] 2. Backend Shot Router Optimization - Replace N+1 query pattern in `list_shots()` endpoint with single JOIN query - Modify shot query to include task status aggregation using SQLAlchemy joins - Update `get_shot()` endpoint to fetch task data in single query - Ensure backward compatibility with existing response format - _Requirements: 1.1, 1.3, 3.1_ - [ ]* 2.1 Write property test for single query shot data fetching - **Property 1: Single Query Data Fetching** - **Validates: Requirements 1.1** - [ ]* 2.2 Write property test for complete shot task status aggregation - **Property 3: Complete Task Status Aggregation** - **Validates: Requirements 1.3** - [x] 3. Backend Asset Router Optimization - Replace N+1 query pattern in `list_assets()` endpoint with single JOIN query - Modify asset query to include task status aggregation using SQLAlchemy joins - Update `get_asset()` endpoint to fetch task data in single query - Ensure backward compatibility with existing response format - _Requirements: 2.1, 2.3, 3.1_ - [ ]* 3.1 Write property test for single query asset data fetching - **Property 1: Single Query Data Fetching** - **Validates: Requirements 2.1** - [ ]* 3.2 Write property test for complete asset task status aggregation - **Property 3: Complete Task Status Aggregation** - **Validates: Requirements 2.3** - [x] 4. Backend Custom Status Support - Ensure optimized queries include both default and custom task statuses - Test with projects that have custom task statuses defined - Verify aggregated data includes all status types - _Requirements: 1.4, 2.4_ - [ ]* 4.1 Write property test for custom status support - **Property 4: Custom Status Support** - **Validates: Requirements 1.4, 2.4** - [ ] 5. Backend Performance Validation - Test optimized queries with datasets of 100+ shots/assets - Measure query execution time and ensure sub-500ms performance - Validate database-level aggregation is being used - _Requirements: 1.5, 2.5, 3.5_ - [ ]* 5.1 Write property test for performance threshold compliance - **Property 5: Performance Threshold Compliance** - **Validates: Requirements 1.5, 2.5** - [ ]* 5.2 Write property test for database-level aggregation - **Property 10: Database-Level Aggregation** - **Validates: Requirements 3.5** - [ ] 6. Checkpoint - Backend Optimization Complete - Ensure all backend tests pass, ask the user if questions arise. - [x] 7. Frontend ShotDetailPanel Component Optimization - Modify `ShotDetailPanel.vue` to use embedded `task_details` data - Remove redundant `taskService.getTasks({ shotId })` API call - Update `loadTasks()` function to use shot.task_details - Test component functionality with embedded data - _Requirements: 1.2, 4.4_ - [ ]* 7.1 Write property test for API call efficiency - **Property 2: API Call Efficiency** - **Validates: Requirements 1.2** - [x] 8. Frontend AssetDetailPanel Component Optimization - Modify `AssetDetailPanel.vue` to use embedded `task_details` data (if component exists) - Remove redundant `taskService.getTasks({ assetId })` API call - Update `loadTasks()` function to use asset.task_details - Test component functionality with embedded data - _Requirements: 2.2, 4.4_ - [x] 9. Frontend TaskBrowser Component Optimization - Modify `TaskBrowser.vue` to extract tasks from shot/asset embedded data - Replace separate `taskService.getTasks()` call with shot/asset data extraction - Update `fetchTasks()` to use Promise.all for shots and assets - Combine task data from both shots and assets - _Requirements: 1.2, 2.2, 4.4_ - [x] 10. Frontend TasksStore Optimization - Modify `TasksStore.ts` to use embedded task data from shots/assets - Update `fetchTasks()` method to get data from shot/asset services - Combine task data from both shots and assets into single array - Maintain existing store interface and computed properties - _Requirements: 1.2, 2.2, 4.4_ - [ ]* 10.1 Write property test for table-optimized data format - **Property 13: Table-Optimized Data Format** - **Validates: Requirements 4.4** - [x] 11. Frontend Custom Task Status Optimization - Create shared store/cache for custom task statuses to eliminate N+1 API calls - Modify EditableTaskStatus components to use cached custom status data - Implement single API call per project for custom task statuses - Update all components that call `customTaskStatusService.getAllStatuses()` - _Requirements: 1.2, 2.2, 4.4_ - [ ]* 11.1 Write property test for custom status API call optimization - **Property 2: API Call Efficiency (Custom Status Variant)** - **Validates: Requirements 1.2, 2.2** - [x] 12. Frontend Response Format Validation - Verify all optimized endpoints return embedded task_statuses field - Ensure task status data includes task type, status, assignee, and updated info - Test frontend components can consume optimized data format - _Requirements: 4.1, 4.2, 4.3_ - [ ]* 12.1 Write property test for embedded task status response - **Property 11: Embedded Task Status Response** - **Validates: Requirements 4.1, 4.2** - [ ]* 12.2 Write property test for complete task status information - **Property 12: Complete Task Status Information** - **Validates: Requirements 4.3** - [ ] 13. Backward Compatibility Testing - Run existing API tests against optimized backend - Verify existing frontend components work with optimized data - Test legacy task query endpoints still function - Ensure no breaking changes in response formats - _Requirements: 5.1, 5.2, 5.3_ - [ ]* 13.1 Write property test for backward compatibility preservation - **Property 15: Backward Compatibility Preservation** - **Validates: Requirements 5.1** - [ ]* 13.2 Write property test for legacy query support - **Property 16: Legacy Query Support** - **Validates: Requirements 5.2** - [ ]* 13.3 Write property test for frontend component compatibility - **Property 17: Frontend Component Compatibility** - **Validates: Requirements 5.3** - [x] 14. Data Consistency and Real-time Updates - Implement data consistency checks between individual task updates and aggregated views - Test real-time update propagation to aggregated data - Ensure task status changes reflect in embedded data - _Requirements: 3.3, 4.5_ - [ ]* 14.1 Write property test for data consistency maintenance - **Property 8: Data Consistency Maintenance** - **Validates: Requirements 3.3** - [ ]* 14.2 Write property test for real-time aggregated updates - **Property 14: Real-Time Aggregated Updates** - **Validates: Requirements 4.5** - [x] 15. Dynamic Task Type Support - Test that new task types are automatically included in aggregated queries - Verify custom task types appear in optimized responses - Test with projects that add new task types after optimization - _Requirements: 3.4_ - [ ]* 15.1 Write property test for dynamic task type inclusion - **Property 9: Dynamic Task Type Inclusion** - **Validates: Requirements 3.4** - [ ] 16. Configuration and Deployment Options - Add optional configuration to enable/disable optimized queries - Implement fallback to legacy query patterns if needed - Create deployment configuration for testing purposes - _Requirements: 5.5_ - [ ]* 16.1 Write property test for configuration flexibility - **Property 19: Configuration Flexibility** - **Validates: Requirements 5.5** - [ ] 17. Integration Testing and Performance Validation - Test end-to-end performance with 100+ shots and assets - Measure total page load time improvements - Validate network request reduction in browser dev tools - Test concurrent user scenarios - _Requirements: 1.5, 2.5_ - [ ]* 17.1 Write property test for optimized SQL join usage - **Property 6: Optimized SQL Join Usage** - **Validates: Requirements 3.1** - [ ] 18. Final Checkpoint - Complete System Validation - Ensure all tests pass, ask the user if questions arise. - Verify both backend and frontend optimizations work together - Confirm performance improvements meet requirements - Validate backward compatibility is maintained