From 63495c665e48847acfa0b0b29322b7990c3d63fb Mon Sep 17 00:00:00 2001 From: Bailey Date: Sat, 13 Jan 2024 09:29:25 -0600 Subject: [PATCH] [610] feat: add more workout details to Sync page (#611) --- src/Api.Contract/PelotonWorkoutsRequest.cs | 8 ++++++-- src/Conversion/IConverter.cs | 21 +++++++++++++-------- src/Peloton/ApiClient.cs | 2 +- src/SharedUI/Pages/Sync.razor | 4 +++- src/SharedUI/Shared/AppSettingsForm.razor | 12 ++++++++++++ vNextReleaseNotes.md | 1 + 6 files changed, 36 insertions(+), 12 deletions(-) diff --git a/src/Api.Contract/PelotonWorkoutsRequest.cs b/src/Api.Contract/PelotonWorkoutsRequest.cs index 6a8587a5a..84c9d38bc 100644 --- a/src/Api.Contract/PelotonWorkoutsRequest.cs +++ b/src/Api.Contract/PelotonWorkoutsRequest.cs @@ -52,8 +52,10 @@ public PelotonWorkout(Workout workout) { Id = workout.Id; Status = workout.Status; - ClassTypeTitle = workout.Title; + PelotonFitnessDiscipline = workout.Fitness_Discipline.ToString(); + IsOutdoor = workout.Is_Outdoor; WorkoutTitle = workout.Ride?.Title; + InstructorName = workout.Ride?.Instructor?.Name; Name = workout.Name; CreatedAt = workout.Created_At; ImageUrl = workout.Ride?.Image_Url; @@ -61,8 +63,10 @@ public PelotonWorkout(Workout workout) public string? Id { get; init; } public string? Status { get; init; } - public string? ClassTypeTitle { get; init; } + public string? PelotonFitnessDiscipline { get; init; } + public bool IsOutdoor { get; init; } public string? WorkoutTitle { get; init; } + public string? InstructorName { get; init; } public string? Name { get; init; } public long CreatedAt { get; init; } public Uri? ImageUrl { get; set; } diff --git a/src/Conversion/IConverter.cs b/src/Conversion/IConverter.cs index bb0bc6f0e..cf344f71f 100644 --- a/src/Conversion/IConverter.cs +++ b/src/Conversion/IConverter.cs @@ -565,17 +565,22 @@ protected static Metric GetMetric(string slug, WorkoutSamples workoutSamples) protected async Task GetDeviceInfoAsync(FitnessDiscipline sport, Settings settings) { - GarminDeviceInfo userProvidedDeviceInfo = await _settingsService.GetCustomDeviceInfoAsync(settings.Garmin.Email); + GarminDeviceInfo deviceInfo = null; + deviceInfo = await _settingsService.GetCustomDeviceInfoAsync(settings.Garmin.Email); - if (userProvidedDeviceInfo is object) return userProvidedDeviceInfo; - - if(sport == FitnessDiscipline.Cycling) - return CyclingDevice; + if (deviceInfo is null) + { + if (sport == FitnessDiscipline.Cycling) + deviceInfo = CyclingDevice; + else if (sport == FitnessDiscipline.Caesar) + deviceInfo = RowingDevice; + else + deviceInfo = DefaultDevice; + } - if (sport == FitnessDiscipline.Caesar) - return RowingDevice; + _logger.Debug("Using device: {@DeviceName}, {@DeviceProdId}, {@DeviceManufacturerId}, {@DeviceVersion}", deviceInfo.Name, deviceInfo.ProductID, deviceInfo.ManufacturerId, deviceInfo.Version); - return DefaultDevice; + return deviceInfo; } protected ushort? GetCyclingFtp(Workout workout, UserData userData) diff --git a/src/Peloton/ApiClient.cs b/src/Peloton/ApiClient.cs index 723c17992..3719d837b 100644 --- a/src/Peloton/ApiClient.cs +++ b/src/Peloton/ApiClient.cs @@ -99,7 +99,7 @@ public async Task> GetWorkoutsAsync(int pageSize, limit = pageSize, sort_by = "-created", page = page, - joins= "ride" + joins= "ride,ride.instructor" }) .StripSensitiveDataFromLogging(auth.Email, auth.Password) .GetJsonAsync>(); diff --git a/src/SharedUI/Pages/Sync.razor b/src/SharedUI/Pages/Sync.razor index e9fa13881..fe2ac9ada 100644 --- a/src/SharedUI/Pages/Sync.razor +++ b/src/SharedUI/Pages/Sync.razor @@ -16,7 +16,9 @@ - + + + diff --git a/src/SharedUI/Shared/AppSettingsForm.razor b/src/SharedUI/Shared/AppSettingsForm.razor index f8337c4cd..381c07156 100644 --- a/src/SharedUI/Shared/AppSettingsForm.razor +++ b/src/SharedUI/Shared/AppSettingsForm.razor @@ -7,6 +7,12 @@ + + ? + @@ -26,6 +32,7 @@ @code { private App appSettings; + private string configDocumentation; public AppSettingsForm() { @@ -45,6 +52,9 @@ var settings = await _apiClient.SettingsGetAsync(); appSettings = settings.App; + + var systemInfo = await _apiClient.SystemInfoGetAsync(new SystemInfoGetRequest() { CheckForUpdate = settings.App.CheckForUpdates }); + configDocumentation = systemInfo.Documentation + "/configuration/json/#app-config"; } protected async Task SaveAppSettings() @@ -69,4 +79,6 @@ Log.Error("UI - Failed to save App settings.", e); } } + + private string AutomaticSyncingDocumentation => $"P2G can periodically and automatically sync workouts. By enabling this setting, P2G will check for workouts every X seconds and sync them. The number of workouts that P2G will fetch per sync can be configured on the Peloton Settings tab.

WARNING: Setting this to a frequency of hourly or less may get you flagged by Peloton as a bad actor and they may reset your password. The default is set to Daily.

Documentation
(click the ? to pin this window)"; } diff --git a/vNextReleaseNotes.md b/vNextReleaseNotes.md index 667f68470..710445d81 100644 --- a/vNextReleaseNotes.md +++ b/vNextReleaseNotes.md @@ -3,6 +3,7 @@ ## Features +- [#610] UI - Add more workout data to Sync page ## Fixes