Skip to content

Feature Request: Recent Workouts Page #12

Description

@brylie

Implement a Recent Workouts page that displays a list of the user's completed workouts, integrated into the existing app structure using Provider for state management.

Objectives

  1. Create a Recent Workouts page accessible from the main screen
  2. Implement data persistence for completed workouts using Drift
  3. Ensure data integrity and support for future migrations
  4. Integrate with existing Provider-based state management
  5. Update the workout screen to allow users to indicate they have completed the workout, so it will be persisted to the database

Requirements

UI/UX

  • Add a calendar icon button to the Choose Workout Category screen, placed next to the dark/light theme toggle in the upper right corner
  • Create a "Recent Workouts" page accessible by tapping the calendar icon
  • Display workouts in a list format, sorted by most recent first
  • For each workout, show:
    • Date of completion
    • List of exercises completed, including:
      • Exercise name
      • Muscle targets
      • Joint targets
  • Implement standard Flutter navigation to allow users to return to the Choose Workout Category screen
  • Implement infinite scrolling or pagination for performance

Data Model and Exercise Management

Exercise Data Management

  • Maintain the current structure of defining exercises as Dart classes for balance, cardio, mobility, strength, and stretching exercises
  • Implement a mechanism to synchronize the Dart-defined exercises with the SQLite database:
    • Create a process to insert/upsert exercises from Dart classes into the Exercise table
    • Ensure this process runs on app initialization and after updates

Data Model

  • Use Drift (SQLite) for local data persistence
  • Create DAOs (Data Access Objects) for CRUD operations on workouts and exercises
  • Design a relational data model that includes:
    • Workout table (id, date)
    • WorkoutExercise table (id, workout_id, exercise_id)
    • Exercise table (id, name, category, muscle_targets, joint_targets, version)
      • Add a 'version' field to track changes in exercise definitions
  • Use appropriate indexing for optimal query performance

Data Synchronization and Migrations

  • Implement a versioning system for the exercise library
  • Create a migration system that can:
    • Initialize the Exercise table with data from Dart classes on first run
    • Upsert exercises when the app is updated and exercise definitions change
    • Handle scenarios where exercises are added, modified, or removed
  • Ensure that historical workout data remains intact and consistent when exercise definitions change

State Management

  • Continue using Provider for state management
  • Create a new Provider for managing Recent Workouts data
  • Integrate the new Provider with existing Providers as necessary

Architecture

  • Maintain the current architecture using Provider
  • Implement a repository pattern for data access
  • Ensure separation of concerns between UI, business logic, and data layers

Testing

  • Write unit tests for data models and repositories
  • Implement integration tests for database operations
  • Create widget tests for the Recent Workouts page and updated Choose Workout Category screen

Additional Tasks

  1. Develop a utility class or function to convert Dart exercise objects to database records
  2. Implement a database seeding mechanism for the initial population of the Exercise table
  3. Create a version tracking system for the exercise library
  4. Develop migration scripts to handle exercise library updates
  5. Implement logic to run necessary migrations on app startup or update

Acceptance Criteria

  1. Users can access the Recent Workouts page by tapping the calendar icon on the Choose Workout Category screen
  2. The Recent Workouts page displays a list of completed workouts with correct information
  3. Workouts are persisted locally and survive app restarts
  4. The implementation uses Drift for data persistence
  5. The data model is designed to support future features and migrations
  6. Provider is used for state management of the Recent Workouts feature
  7. Users can navigate back to the Choose Workout Category screen from the Recent Workouts page
  8. Unit, integration, and widget tests are implemented with >80% coverage
  9. Exercise data from Dart classes is correctly synchronized with the SQLite database
  10. Updates to the exercise library in Dart code are reflected in the database after app updates
  11. Historical workout data remains consistent and accessible after exercise library updates

Future Considerations

While not part of this feature request, keep the following future enhancements in mind:

  1. Calendar view of workouts
  2. Statistical analysis of workout history
  3. Muscle group and joint engagement tracking
  4. Anatomical display of exercise focus areas
  5. Workout recommendations based on history
  6. Sync capabilities with cloud storage

Implementation Notes

  • Ensure the new Recent Workouts feature integrates smoothly with the existing app structure and navigation flow
  • Use caution when designing the data model to ensure it can handle future changes to exercise lists or categories without breaking historical data
  • Implement proper database migrations to support schema changes over time
  • Consider using type-safe queries and code generation features of Drift to catch potential issues at compile-time
  • Document any assumptions made about the data model or potential limitations for future reference
  • Develop a robust synchronization mechanism between Dart-defined exercises and the SQLite database
  • Implement a versioning system for exercise definitions to track changes over time
  • Create a migration strategy that can handle updates to the exercise library without compromising historical workout data
  • Consider edge cases such as exercises being removed or significantly modified, and how this affects the display and analysis of historical workouts
  • Document the process for updating the exercise library, including any necessary steps for database migration

Resources

Definition of Done

  • Feature is implemented and meets all requirements
  • Code is reviewed and approved by at least one other developer
  • All tests are passing with required coverage
  • Documentation is updated, including any necessary migration guides
  • Feature is tested on all supported platforms (Web, iOS, Android)
  • Performance is verified to meet or exceed existing app standards
  • Exercise synchronization mechanism is implemented and tested
  • Migration system for exercise library updates is in place and verified
  • Documentation is updated to include the process for modifying the exercise library and its impact on the database

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions