FitTrackee icon indicating copy to clipboard operation
FitTrackee copied to clipboard

WIP: New equipment for workouts

Open jat255 opened this issue 2 years ago • 3 comments

This is still a WIP, but wanted to hopefully get some feedback. I'm pretty sure I'm done with the DB and API side of things on this addition, but still have to do the front-end stuff.

Resolves #259

Running todo:

  • Equipment support:
    • Database models:
      • [x] Add models for Equipment, Equipment type, workout/equipment M2M
    • API:
      • [x] Getting all equipment (for user or all as admin)
      • [x] Get equipment by type id
      • [x] Getting single equipment (for user or admin)
      • [x] Creating equipment
      • [x] Updating equipment
      • [x] Deleting equipment
      • [x] Associating workout with equipment
      • [x] Setting default equipment for sport type (user preferences)
    • API tests:
      • [x] GET /equipment_types
      • [x] GET /equipment_types/id
      • [x] GET /equipment
      • [x] GET /equipment/id
      • [x] POST /equipment
      • [x] PATCH /equipment/id
      • [x] DELETE /equipment/id
        • [x] test cascading of deletions to workout
        • [x] test cascading of deletions to default workout
      • [x] POST /auth/profile/edit/sports
      • [x] DELETE of user should delete any equipment they have
    • Front end:
      • [x] Displaying table of equipment
        • Creation date
        • Number of workouts
        • Number of miles
        • Total time
      • [ ] Setting default for sport from user preferences
      • [x] Choosing equipment during workout creation/edit
        • Should default to any existing default when a sport is chosen
      • [x] Displaying equipment in workout details
      • [x] Adding equipment to filters on workout list

jat255 avatar Mar 26 '23 18:03 jat255

Hi, Thanks for starting the implementation.

I will take a look at it soon. No need to start the front-end for now, due to the upcoming changes with social features.

SamR1 avatar May 03 '23 06:05 SamR1

I will take a look at it soon. No need to start the front-end for now, due to the upcoming changes with social features.

That's great, since I quickly realized I was in over my head (I have no idea how to do front-end dev), and wasn't making much progress :sweat_smile:

jat255 avatar May 10 '23 04:05 jat255

Hi @jat255

I'm really sorry for the late feedback.
I had originally planned to take a look, after the social features (but there's still some work to do).

I've made a few changes :

  • rename equipment to equipments
  • dedicated OAuth2 scope for equipments
  • I removed treadmill because there's no sport for it
  • it's now possible to add several default equipments to a sport
  • I added a few tests and did some changes on database model and refactoring

And there's still the part on default equipments to implement on the client side.

Thanks again for starting the implementation.


Some screenshots (may change):

  • Administration

Screenshot 2024-03-06 at 20-35-53 FitTrackee - Equipments administration

  • User Equipements

Screenshot 2024-03-06 at 20-43-58 FitTrackee - Équipements

Screenshot 2024-03-06 at 20-31-56 FitTrackee - Equipments

It remains to display distance correctly.

  • Equipments on Workout detail

Screenshot 2024-03-06 at 20-32-35 FitTrackee - Workout

  • Filter on Equipement on Workout List

Screenshot 2024-03-06 at 20-32-10 FitTrackee - Workouts

  • Workout creation

Screenshot 2024-03-06 at 20-33-08 FitTrackee - Add a workout

SamR1 avatar Mar 06 '24 19:03 SamR1

Additional changes on API side:

  • store equipement totals in equipments table (to avoid fetching all related workouts to calculate totals)
  • unique contraint on label and user_id only for equipments table to avoid error when selecting an equipment with same label
  • POST /workout & POST /workout/no_gpx: if equipment_ids is not provided and default equipment exists for the sport, they will be associated to make it easier to add equipments using only the API (for instance with an import script)

Screenshots

  • updated equipment detail

Screenshot 2024-03-17 at 12-29-04 FitTrackee - Equipments

  • sport detail (new page)

Screenshot 2024-03-17 at 12-29-09 FitTrackee - Sports

SamR1 avatar Mar 17 '24 11:03 SamR1

Last changes:

  • handle equipment types deactivation (to match sports deactivated by admin)
  • it is not possible to create an equipment with a deactivated type
  • only valid equipement for a given sport can be added

SamR1 avatar Apr 10 '24 17:04 SamR1