Skip to content

Commit

Permalink
chore: format code with csharpier
Browse files Browse the repository at this point in the history
  • Loading branch information
renovate[bot] authored and github-actions[bot] committed Nov 18, 2024
1 parent eac6229 commit 0388304
Show file tree
Hide file tree
Showing 8 changed files with 154 additions and 145 deletions.
13 changes: 6 additions & 7 deletions LiftLog.Api/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -76,13 +76,12 @@
"notasecret",
X509KeyStorageFlags.Exportable
);
ServiceAccountCredential credential =
new(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AndroidPublisherService.Scope.Androidpublisher },
}.FromCertificate(certificate)
);
ServiceAccountCredential credential = new(
new ServiceAccountCredential.Initializer(serviceAccountEmail)
{
Scopes = new[] { AndroidPublisherService.Scope.Androidpublisher },
}.FromCertificate(certificate)
);
return new AndroidPublisherService(
new AndroidPublisherService.Initializer
{
Expand Down
22 changes: 10 additions & 12 deletions LiftLog.Api/Service/GptAiWorkoutPlanner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,20 @@ public class GptAiWorkoutPlanner(OpenAIClient openAiClient, ILogger<GptAiWorkout
private static readonly JsonNode aiWorkoutPlanJsonSchema = JsonNode.Parse(
File.ReadAllText("./AiWorkoutPlan.json")
)!;
private static readonly Function GetGymPlanFunction =
new(
"GetGymPlan",
"Gets a gym plan based on the user's goals and attributes.",
aiWorkoutPlanJsonSchema
);
private static readonly Function GetGymPlanFunction = new(
"GetGymPlan",
"Gets a gym plan based on the user's goals and attributes.",
aiWorkoutPlanJsonSchema
);

private static readonly JsonNode sessionBlueprintJsonSchema = JsonNode.Parse(
File.ReadAllText("./AiSessionBlueprint.json")
)!;
private static readonly Function GetSessionFunction =
new(
"GetSession",
"Gets a gym session based on the user's goals and attributes.",
sessionBlueprintJsonSchema
);
private static readonly Function GetSessionFunction = new(
"GetSession",
"Gets a gym session based on the user's goals and attributes.",
sessionBlueprintJsonSchema
);

public async Task<AiWorkoutPlan> GenerateWorkoutPlanAsync(AiWorkoutAttributes attributes)
{
Expand Down
42 changes: 25 additions & 17 deletions LiftLog.Lib/Models/BlueprintModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,16 @@ public record ExerciseBlueprint(
string Link
)
{
public static readonly ExerciseBlueprint Default =
new(
Name: string.Empty,
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 0,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: string.Empty,
Link: string.Empty
);
public static readonly ExerciseBlueprint Default = new(
Name: string.Empty,
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 0,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: string.Empty,
Link: string.Empty
);
}

public record KeyedExerciseBlueprint(string Name, int Sets, int RepsPerSet)
Expand Down Expand Up @@ -98,12 +97,21 @@ string when lowerName.EndsWith('s') => lowerName[..^1],

public record Rest(TimeSpan MinRest, TimeSpan MaxRest, TimeSpan FailureRest)
{
public static readonly Rest Short =
new(TimeSpan.FromSeconds(60), TimeSpan.FromSeconds(90), TimeSpan.FromSeconds(180));
public static readonly Rest Short = new(
TimeSpan.FromSeconds(60),
TimeSpan.FromSeconds(90),
TimeSpan.FromSeconds(180)
);

public static readonly Rest Medium =
new(TimeSpan.FromSeconds(90), TimeSpan.FromSeconds(180), TimeSpan.FromSeconds(300));
public static readonly Rest Medium = new(
TimeSpan.FromSeconds(90),
TimeSpan.FromSeconds(180),
TimeSpan.FromSeconds(300)
);

public static readonly Rest Long =
new(TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(5), TimeSpan.FromMinutes(8));
public static readonly Rest Long = new(
TimeSpan.FromMinutes(3),
TimeSpan.FromMinutes(5),
TimeSpan.FromMinutes(8)
);
}
9 changes: 7 additions & 2 deletions LiftLog.Lib/Models/SessionModels.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,13 @@ public record Session(
decimal? Bodyweight
)
{
public static readonly Session Empty =
new(Guid.Empty, SessionBlueprint.Empty, [], DateOnly.MinValue, null);
public static readonly Session Empty = new(
Guid.Empty,
SessionBlueprint.Empty,
[],
DateOnly.MinValue,
null
);

public static Session FreeformSession(DateOnly date, decimal? bodyweight) =>
Empty with
Expand Down
75 changes: 37 additions & 38 deletions LiftLog.Ui/Pages/Screenshot/ScreenshotCollectorPage.Home.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,44 +9,43 @@ namespace LiftLog.Ui.Pages.Screenshot;

public partial class ScreenshotCollectorPage
{
private SessionBlueprint demoSessionBlueprint =
new(
Name: "Session 1",
Exercises:
[
new ExerciseBlueprint(
Name: "Squat",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
new ExerciseBlueprint(
Name: "Bench Press",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
new ExerciseBlueprint(
Name: "Deadlift",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
],
Notes: ""
);
private SessionBlueprint demoSessionBlueprint = new(
Name: "Session 1",
Exercises:
[
new ExerciseBlueprint(
Name: "Squat",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
new ExerciseBlueprint(
Name: "Bench Press",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
new ExerciseBlueprint(
Name: "Deadlift",
Sets: 3,
RepsPerSet: 10,
WeightIncreaseOnSuccess: 2.5m,
RestBetweenSets: Rest.Medium,
SupersetWithNext: false,
Notes: "",
Link: ""
),
],
Notes: ""
);

private async Task HandleHomeScreenshotCollection()
{
Expand Down
37 changes: 18 additions & 19 deletions LiftLog.Ui/Store/App/AppState.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,25 +21,24 @@ public record AppState(
(int Year, int Month)? HistoryYearMonth
)
{
public static readonly AppState InitialState =
new(
Title: "LiftLog",
IsHydrated: false,
ProState: new ProState(ProToken: null),
ReopenCurrentSessionTargets:
[
SessionTarget.WorkoutSession,
SessionTarget.HistorySession,
SessionTarget.FeedSession,
],
BackNavigationUrl: null,
LatestSettingsUrl: null,
HasRequestedNotificationPermission: false,
ColorScheme: new AppColorScheme<uint>(),
AppLaunchCount: 0,
AppRatingResult: AppRatingResult.NotRated,
HistoryYearMonth: null
);
public static readonly AppState InitialState = new(
Title: "LiftLog",
IsHydrated: false,
ProState: new ProState(ProToken: null),
ReopenCurrentSessionTargets:
[
SessionTarget.WorkoutSession,
SessionTarget.HistorySession,
SessionTarget.FeedSession,
],
BackNavigationUrl: null,
LatestSettingsUrl: null,
HasRequestedNotificationPermission: false,
ColorScheme: new AppColorScheme<uint>(),
AppLaunchCount: 0,
AppRatingResult: AppRatingResult.NotRated,
HistoryYearMonth: null
);
};

public enum AppRatingResult
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ public class SharedItemIntegrationTests(WebApplicationFactory<Program> factory)
: IClassFixture<WebApplicationFactory<Program>>
{
const string url = "/shareditem";
private static readonly AesEncryptedAndRsaSignedData encryptedPayload =
new([0x01, 0x02, 0x03], new(Enumerable.Repeat((byte)0x04, 16).ToArray()));
private static readonly AesEncryptedAndRsaSignedData encryptedPayload = new(
[0x01, 0x02, 0x03],
new(Enumerable.Repeat((byte)0x04, 16).ToArray())
);
private static readonly byte[] rsaPublicKey = Enumerable.Repeat((byte)0x05, 16).ToArray();
private readonly WebApplicationFactory<Program> _factory = factory;

Expand Down
95 changes: 47 additions & 48 deletions tests/LiftLog.Tests.App/Reducers/CurrentSessionReducerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,55 +5,54 @@ namespace LiftLog.Tests.Reducers;

public class CurrentSessionReducerTests
{
private static readonly CurrentSessionState _initialState =
new(
IsHydrated: true,
WorkoutSession: Sessions.CreateSession(
null,
session =>
session with
{
RecordedExercises = session
.RecordedExercises.SetItem(
0,
Sessions.CreateRecordedExercise(
exerciseIndex: 0,
null,
exercise =>
exercise with
{
PerSetWeight = false,
Weight = 10m,
PotentialSets = Sessions
.CreatePotentialSet(10m, isEmpty: true)
.Repeat(exercise.Blueprint.Sets - 1)
.Add(Sessions.CreatePotentialSet(10m)),
}
)
private static readonly CurrentSessionState _initialState = new(
IsHydrated: true,
WorkoutSession: Sessions.CreateSession(
null,
session =>
session with
{
RecordedExercises = session
.RecordedExercises.SetItem(
0,
Sessions.CreateRecordedExercise(
exerciseIndex: 0,
null,
exercise =>
exercise with
{
PerSetWeight = false,
Weight = 10m,
PotentialSets = Sessions
.CreatePotentialSet(10m, isEmpty: true)
.Repeat(exercise.Blueprint.Sets - 1)
.Add(Sessions.CreatePotentialSet(10m)),
}
)
.SetItem(
1,
Sessions.CreateRecordedExercise(
exerciseIndex: 1,
null,
exercise =>
exercise with
{
PerSetWeight = true,
Weight = 20m,
PotentialSets = Sessions
.CreatePotentialSet(20m, isEmpty: true)
.Repeat(exercise.Blueprint.Sets - 1)
.Add(Sessions.CreatePotentialSet(60m)),
}
)
),
}
),
HistorySession: null,
FeedSession: null,
LatestSetTimerNotificationId: null
);
)
.SetItem(
1,
Sessions.CreateRecordedExercise(
exerciseIndex: 1,
null,
exercise =>
exercise with
{
PerSetWeight = true,
Weight = 20m,
PotentialSets = Sessions
.CreatePotentialSet(20m, isEmpty: true)
.Repeat(exercise.Blueprint.Sets - 1)
.Add(Sessions.CreatePotentialSet(60m)),
}
)
),
}
),
HistorySession: null,
FeedSession: null,
LatestSetTimerNotificationId: null
);

[Describe("CurrentSessionReducer")]
public static void Spec()
Expand Down

0 comments on commit 0388304

Please sign in to comment.