Skip to content

Commit 0280daa

Browse files
committed
Modify requirement for stats in dev version
1 parent 267e558 commit 0280daa

File tree

4 files changed

+27
-16
lines changed

4 files changed

+27
-16
lines changed

src/AzzyBot-Next/Extensions/ServiceCollectionExtensions.cs

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -109,18 +109,22 @@ public static void AzzyBotSettings(this IServiceCollection services, bool isDev
109109
services.AddSingleton(settings);
110110
}
111111

112-
public static void AzzyBotStats(this IServiceCollection services)
112+
public static void AzzyBotStats(this IServiceCollection services, bool isDev)
113113
{
114-
string path = Path.Combine("Modules", "Core", "Files", "AzzyBotStats.json");
115-
116-
AzzyBotStatsRecord? stats = GetConfiguration(path).Get<AzzyBotStatsRecord>();
117-
if (stats is null)
114+
AzzyBotStatsRecord? stats = new("Unkown", DateTime.Now, 0);
115+
if (!isDev)
118116
{
119-
Console.Error.Write("There is something wrong with your configuration. Did you followed the installation instructions?");
120-
if (!AzzyStatsHardware.CheckIfLinuxOs)
121-
Console.ReadKey();
117+
string path = Path.Combine("Modules", "Core", "Files", "AzzyBotStats.json");
122118

123-
Environment.Exit(1);
119+
stats = GetConfiguration(path).Get<AzzyBotStatsRecord>();
120+
if (stats is null)
121+
{
122+
Console.Error.Write("There is something wrong with your configuration. Did you followed the installation instructions?");
123+
if (!AzzyStatsHardware.CheckIfLinuxOs)
124+
Console.ReadKey();
125+
126+
Environment.Exit(1);
127+
}
124128
}
125129

126130
services.AddSingleton(stats);
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"Commit": "12345",
3-
"CompilationDate": "2024-07-06",
4-
"LocCS": "12345"
2+
"Commit": "Commit not found",
3+
"CompilationDate": "Compilation date not found",
4+
"LocCS": "Lines of source code not found"
55
}

src/AzzyBot-Next/Settings/AzzyBotStatsRecord.cs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,11 +6,18 @@ namespace AzzyBot.Settings;
66
public sealed record AzzyBotStatsRecord
77
{
88
[JsonPropertyName(nameof(Commit))]
9-
public required string Commit { get; init; }
9+
public string Commit { get; init; }
1010

1111
[JsonPropertyName(nameof(CompilationDate))]
12-
public required DateTime CompilationDate { get; init; }
12+
public DateTime CompilationDate { get; init; }
1313

1414
[JsonPropertyName(nameof(LocCs))]
15-
public required int LocCs { get; init; }
15+
public int LocCs { get; init; }
16+
17+
public AzzyBotStatsRecord(string commit, in DateTime compilationDate, int locCs)
18+
{
19+
Commit = commit;
20+
CompilationDate = compilationDate;
21+
LocCs = locCs;
22+
}
1623
}

src/AzzyBot-Next/Startup.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public static async Task Main(string[] args)
5050
#region Add services
5151

5252
appBuilder.Services.AzzyBotSettings(isDev, isDocker);
53-
appBuilder.Services.AzzyBotStats();
53+
appBuilder.Services.AzzyBotStats(isDev);
5454
appBuilder.Services.AzzyBotServices();
5555

5656
#endregion Add services

0 commit comments

Comments
 (0)