diff --git a/mkdocs/docs/configuration/json.md b/mkdocs/docs/configuration/json.md index dfbccf93b..8d1797225 100644 --- a/mkdocs/docs/configuration/json.md +++ b/mkdocs/docs/configuration/json.md @@ -212,6 +212,7 @@ The available values are: ```json Cycling + Outdoor Cycling BikeBootcamp TreadmillRunning OutdoorRunning diff --git a/src/Common/Dto/P2GWorkout.cs b/src/Common/Dto/P2GWorkout.cs index d98585590..e6c29defc 100644 --- a/src/Common/Dto/P2GWorkout.cs +++ b/src/Common/Dto/P2GWorkout.cs @@ -34,6 +34,7 @@ public static WorkoutType GetWorkoutType(this Workout workout) FitnessDiscipline.Caesar => WorkoutType.Rowing, FitnessDiscipline.Cardio => WorkoutType.Cardio, FitnessDiscipline.Circuit => WorkoutType.Circuit, + FitnessDiscipline.Cycling when workout.Is_Outdoor => WorkoutType.OutdoorCycling, FitnessDiscipline.Cycling => WorkoutType.Cycling, FitnessDiscipline.Meditation => WorkoutType.Meditation, FitnessDiscipline.Strength => WorkoutType.Strength, diff --git a/src/Common/Dto/WorkoutType.cs b/src/Common/Dto/WorkoutType.cs index b20c4d053..91a46829e 100644 --- a/src/Common/Dto/WorkoutType.cs +++ b/src/Common/Dto/WorkoutType.cs @@ -16,5 +16,6 @@ public enum WorkoutType : byte Yoga = 11, Meditation = 12, Rowing = 13, + OutdoorCycling = 14, } } diff --git a/src/UnitTests/Common/Dto/P2GWorkoutTests.cs b/src/UnitTests/Common/Dto/P2GWorkoutTests.cs index 1c3dc0c85..94b93595d 100644 --- a/src/UnitTests/Common/Dto/P2GWorkoutTests.cs +++ b/src/UnitTests/Common/Dto/P2GWorkoutTests.cs @@ -26,6 +26,7 @@ public void GetWorkoutType_Should_Map_Correctly([Values]FitnessDiscipline fitnes case FitnessDiscipline.Cardio: workoutType.Should().Be(WorkoutType.Cardio); break; case FitnessDiscipline.Caesar: workoutType.Should().Be(WorkoutType.Rowing); break; case FitnessDiscipline.Circuit: workoutType.Should().Be(WorkoutType.Circuit); break; + case FitnessDiscipline.Cycling when isOutdoor: workoutType.Should().Be(WorkoutType.OutdoorCycling); break; case FitnessDiscipline.Cycling: workoutType.Should().Be(WorkoutType.Cycling); break; case FitnessDiscipline.Meditation: workoutType.Should().Be(WorkoutType.Meditation); break; case FitnessDiscipline.Strength: workoutType.Should().Be(WorkoutType.Strength); break; diff --git a/src/UnitTests/Sync/SyncServiceTests.cs b/src/UnitTests/Sync/SyncServiceTests.cs index 9b5b62bd6..2004f6190 100644 --- a/src/UnitTests/Sync/SyncServiceTests.cs +++ b/src/UnitTests/Sync/SyncServiceTests.cs @@ -304,5 +304,51 @@ public async Task SyncAsync_When_CheckForUpdates_Disabled_Should_NotCheck() // ASSERT ghService.Verify(x => x.GetLatestReleaseInformationAsync("philosowaffle", "peloton-to-garmin", Constants.AppVersion), Times.Never); } + + [Test] + public async Task SyncAsync_When_Should_Excluded_ExcludedWorkoutTypes() + { + // SETUP + var mocker = new AutoMocker(); + + var service = mocker.CreateInstance(); + var peloton = mocker.GetMock(); + var db = mocker.GetMock(); + var converter = mocker.GetMock(); + var garmin = mocker.GetMock(); + var fileHandler = mocker.GetMock(); + var settingsService = mocker.GetMock(); + + var settings = new Settings(); + settings.Format.Fit = true; + settings.App.CheckForUpdates = false; + settings.Peloton.ExcludeWorkoutTypes = new List() { WorkoutType.OutdoorCycling }; + settingsService.Setup(s => s.GetSettingsAsync()).ReturnsAsync(settings); + + var syncStatus = new SyncServiceStatus(); + db.Setup(x => x.GetSyncStatusAsync()).Returns(Task.FromResult(syncStatus)); + + var workout = new Workout() { Status = "COMPLETE", Id = "1", Is_Outdoor = true, Fitness_Discipline = FitnessDiscipline.Cycling }; + peloton.Setup(x => x.GetRecentWorkoutsAsync(0)).ReturnsAsync(new List() { workout }.AsServiceResult()); + + var p2gWorkout = new P2GWorkout() { Workout = workout }; + peloton.Setup(x => x.GetWorkoutDetailsAsync(It.IsAny>())).ReturnsAsync(new P2GWorkout[] { p2gWorkout }); + + // ACT + var response = await service.SyncAsync(0); + + // ASSERT + response.SyncSuccess.Should().BeTrue(); + response.PelotonDownloadSuccess.Should().BeTrue(); + response.ConversionSuccess.Should().BeTrue(); + response.UploadToGarminSuccess.Should().BeNull(); + response.Errors.Should().BeNullOrEmpty(); + + peloton.Verify(x => x.GetRecentWorkoutsAsync(0), Times.Once); + converter.Verify(x => x.ConvertAsync(It.IsAny()), Times.Never); + garmin.Verify(x => x.UploadToGarminAsync(), Times.Never); + db.Verify(x => x.UpsertSyncStatusAsync(It.IsAny()), Times.Once); + fileHandler.Verify(x => x.Cleanup(It.IsAny()), Times.Never); + } } } diff --git a/vNextReleaseNotes.md b/vNextReleaseNotes.md index 643a776d2..f0d680be6 100644 --- a/vNextReleaseNotes.md +++ b/vNextReleaseNotes.md @@ -4,6 +4,7 @@ ## Features - [#564] Set a custom title prefix on Workouts +- [#559] Ability to exclude Outdoor Cycling workouts from sycning ## Docker Tags