Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(app): Add workout filtering and sorting #331

Merged
merged 2 commits into from
Nov 27, 2024

Conversation

jovandeginste
Copy link
Owner

This commit introduces filtering and sorting capabilities to the workout list
view. This enhances the user experience by allowing users to easily find
specific workouts based on various criteria.

The changes include:

  • Add a new WorkoutFilters struct to encapsulate filter parameters. This
    allows for easier handling and validation of filter input.
  • Create new template functions to provide options for the different filters and
    sorting, such as filterOptions, orderByOptions, and orderDirOptions.
  • Implement the WorkoutFilters struct to handle filtering by workout type, and
    time period, and sorting based on specific fields.
  • Modify the workoutsHandler function to utilize the WorkoutFilters struct
    to apply filters to the database query.
  • Added filter elements to the workouts view, allowing users to select filters
    and apply them. These elements are dynamically populated with options from the
    new template functions.
  • Updated the database queries to support the new filtering and sorting logic.
    This involves using the new GetDateLimitExpression function to correctly
    handle time-based filters and adding support for sorting by different fields.
    All this is encapsulated within the new WorkoutFilters struct.
  • Add translations for the new filter options.

This commit introduces filtering and sorting capabilities to the workout list
view. This enhances the user experience by allowing users to easily find
specific workouts based on various criteria.

The changes include:

- Add a new `WorkoutFilters` struct to encapsulate filter parameters. This
  allows for easier handling and validation of filter input.
- Create new template functions to provide options for the different filters and
  sorting, such as `filterOptions`, `orderByOptions`, and `orderDirOptions`.
- Implement the `WorkoutFilters` struct to handle filtering by workout type, and
  time period, and sorting based on specific fields.
- Modify the `workoutsHandler` function to utilize the `WorkoutFilters` struct
  to apply filters to the database query.
- Added filter elements to the workouts view, allowing users to select filters
  and apply them. These elements are dynamically populated with options from the
  new template functions.
- Updated the database queries to support the new filtering and sorting logic.
  This involves using the new `GetDateLimitExpression` function to correctly
  handle time-based filters and adding support for sorting by different fields.
  All this is encapsulated within the new `WorkoutFilters` struct.
- Add translations for the new filter options.
The `getWorkoutsFilters` function was not handling errors properly, which could
lead to unexpected behavior. This commit modifies the function to return an
error if binding fails and adds error handling in the `workoutsHandler` to
redirect to the workouts page with the error.

Additionally, the `AverageSpeed` and `AverageSpeedNoPause` fields in the
`WorkoutData` struct were methods, and not fields.
@jovandeginste jovandeginste merged commit 619ece7 into master Nov 27, 2024
3 checks passed
@jovandeginste jovandeginste deleted the workouts-list-filter branch November 27, 2024 12:06
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