Raistlfiren / garmin-csv-plan

A quick n' dirty way of "automating" training plans into Garmin Connect.
https://raistlfiren.github.io/garmin-csv-plan/
37 stars 6 forks source link

Support multiple sessions per day #19

Closed pygoubet closed 3 years ago

pygoubet commented 3 years ago

Hi, The feature introduced in PR #6 has stopped working. Could you consider re-adding the ability to encode several workouts on the same day?

Raistlfiren commented 3 years ago

@pygoubet - Can you test out the latest release to see if this works properly again?

Thanks!

pygoubet commented 3 years ago

@Raistlfiren thanks for the feature It seems it remains a little something to fix... ./bin/console garmin:workout tests/Resource/multi-events-day.csv schedule --start 2021-05-17 --no-interaction -x

All defined workouts are created: OK

Creating workouts
-----------------

 * Workout - 10x30''30'' was created on the Garmin website with the id 341278695
 * Workout - easy cycle was created on the Garmin website with the id 341278697
 * Workout - easy run was created on the Garmin website with the id 341278698
 * Workout - long run was created on the Garmin website with the id 341278699

But the 3rd workout of planned on Monday is not scheduled:

Scheduling workouts
-------------------

 * Workout - 10x30''30'' with id 341278695 was scheduled on the Garmin website for 2021-05-17
 * Workout - easy cycle with id 341278697 was scheduled on the Garmin website for 2021-05-17
 * Workout - long run with id 341278699 was scheduled on the Garmin website for 2021-05-19

I can reproduce the problem with a CSV file of my own. The last workout of a day with several multiple workouts is not scheduled.

pygoubet commented 3 years ago

It seems to be related to a variable passed by reference issue. Below a quick (and dirty?) workaround. File: src/Library/Parser/Parser.php

  1. comment lines 167-171
  2. change line 182 to: if ($workout->getName() === $this->parseWorkoutName($workoutName)) {
Raistlfiren commented 3 years ago

Thanks @pygoubet - Commenting out those lines will cause problems. I just pushed a fix that should address your problem. Please test it again and see if there are any issues now.

pygoubet commented 3 years ago

@Raistlfiren thank you for the fix. It works fine.