Skip to content

Commit 4389ae6

Browse files
committed
fix smells
1 parent 7d4a9b4 commit 4389ae6

5 files changed

Lines changed: 12 additions & 33 deletions

File tree

NetEvent/Client/Pages/Administration/SystemInfo.razor

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
</MudTable>
7272
</MudTabPanel>
7373
<MudTabPanel Text="@Localize["Administration.Systeminfo.ClientComponents"]">
74-
<MudTable Items="@_ClientComponents" Dense="true" Hover="true" Bordered="false" Striped="true" Filter="new Func<SystemInfoComponentEntryDto,bool>(FilterFuncClientComponents1)">
74+
<MudTable Items="@_ClientComponents" Dense="true" Hover="true" Bordered="false" Striped="true" Filter="new Func<SystemInfoComponentEntryDto,bool>(FilterFuncComponents1)">
7575
<ToolBarContent>
7676
<MudSpacer />
7777
<MudTextField @bind-Value="searchStringClientComponents" Placeholder="@Localize["Administration.Systeminfo.ClientComponents.SearchPlaceholder"]" Adornment="Adornment.Start" AdornmentIcon="@Icons.Material.Filled.Search" IconSize="Size.Medium" Class="mt-0"></MudTextField>

NetEvent/Client/Pages/Administration/SystemInfo.razor.cs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,6 @@ public partial class SystemInfo
1717
private ISystemInfoDataService _SystemInfoDataService { get; set; } = default!;
1818

1919
#endregion
20-
21-
// TODO: deceide if _ClientComponents should be SystemInfoComponentEntryDto or not
2220
private readonly IList<SystemInfoComponentEntryDto> _ClientComponents = new List<SystemInfoComponentEntryDto>();
2321
private SystemInfoDto _SystemInfos = new SystemInfoDto();
2422
private string searchStringComponents = string.Empty;
@@ -39,7 +37,6 @@ protected override async Task OnInitializedAsync()
3937
}
4038
}
4139

42-
// TODO: maybe consolidate filter functions?
4340
private bool FilterFuncComponents1(SystemInfoComponentEntryDto systeminfocomponententry) => FilterFuncComponents(systeminfocomponententry, searchStringComponents);
4441

4542
private static bool FilterFuncComponents(SystemInfoComponentEntryDto systeminfocomponententry, string searchString)
@@ -62,28 +59,6 @@ private static bool FilterFuncComponents(SystemInfoComponentEntryDto systeminfoc
6259
return false;
6360
}
6461

65-
private bool FilterFuncClientComponents1(SystemInfoComponentEntryDto systeminfocomponententry) => FilterFuncClientComponents(systeminfocomponententry, searchStringClientComponents);
66-
67-
private static bool FilterFuncClientComponents(SystemInfoComponentEntryDto systeminfocomponententry, string searchString)
68-
{
69-
if (string.IsNullOrWhiteSpace(searchString))
70-
{
71-
return true;
72-
}
73-
74-
if (systeminfocomponententry.Component.Contains(searchString, StringComparison.OrdinalIgnoreCase))
75-
{
76-
return true;
77-
}
78-
79-
if (systeminfocomponententry.Version.Contains(searchString, StringComparison.OrdinalIgnoreCase))
80-
{
81-
return true;
82-
}
83-
84-
return false;
85-
}
86-
8762
private bool FilterFuncVersions1(SystemInfoVersionEntryDto systeminfoversionentry) => FilterFuncVersions(systeminfoversionentry, searchStringVersions);
8863

8964
private static bool FilterFuncVersions(SystemInfoVersionEntryDto systeminfoversionentry, string searchString)

NetEvent/Client/Services/SystemInfoDataService.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using System;
2+
using System.Diagnostics.CodeAnalysis;
23
using System.Net.Http;
34
using System.Net.Http.Json;
45
using System.Threading;
@@ -8,6 +9,7 @@
89

910
namespace NetEvent.Client.Services
1011
{
12+
[ExcludeFromCodeCoverage(Justification = "Ignore UI Services")]
1113
public class SystemInfoDataService : ISystemInfoDataService
1214
{
1315
private readonly IHttpClientFactory _HttpClientFactory;

NetEvent/Server.Tests/SystemModuleTest.cs

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ public async Task GetSystemInfoVersionsSetted_Test()
115115
Assert.NotNull(response?.Versions);
116116
Assert.NotEmpty(response?.Health);
117117
Assert.NotEmpty(response?.Versions);
118-
Assert.NotEqual(0, response?.Health.Count);
119-
Assert.NotEqual(0, response?.Versions.Count);
120118
Assert.Equal("TEST", response?.Versions?.Find(x => x.Component.Equals("BUILDNODE"))?.Version);
121119
Assert.Equal("TEST", response?.Versions?.Find(x => x.Component.Equals("BUILDID"))?.Version);
122120
Assert.Equal("TEST", response?.Versions?.Find(x => x.Component.Equals("BUILDNUMBER"))?.Version);

NetEvent/Server/Modules/System/Endpoints/GetSystemInfo/GetSystemInfoHandler.cs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@ public Task<GetSystemInfoResponse> Handle(GetSystemInfoRequest request, Cancella
2727
systeminfocomponents.Add(new SystemInfoComponentEntryDto(assem.ManifestModule.Name.ToString(), assem.ToString()));
2828
}
2929

30-
// TODO: is it possible to make that better?
3130
systeminfoversions.Add(new SystemInfoVersionEntryDto("NETEVENT", Assembly.GetEntryAssembly()?.GetCustomAttribute<AssemblyInformationalVersionAttribute>()?.InformationalVersion));
32-
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDNODE", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDNODE")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
33-
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDID", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDID")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
34-
systeminfoversions.Add(new SystemInfoVersionEntryDto("BUILDNUMBER", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("BUILDNUMBER")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
35-
systeminfoversions.Add(new SystemInfoVersionEntryDto("SOURCE_COMMIT", string.IsNullOrEmpty(Environment.GetEnvironmentVariable("SOURCE_COMMIT")) ? "dev" : Environment.GetEnvironmentVariable("BUILDNODE")));
31+
systeminfoversions.Add(CreateSystemInfoVersionEntryFromEnv("BUILDNODE"));
32+
systeminfoversions.Add(CreateSystemInfoVersionEntryFromEnv("BUILDID"));
33+
systeminfoversions.Add(CreateSystemInfoVersionEntryFromEnv("BUILDNUMBER"));
34+
systeminfoversions.Add(CreateSystemInfoVersionEntryFromEnv("SOURCE_COMMIT"));
3635

3736
// TODO: think about healthchecks and healthcheck modularity (to perform checks on various services like game servers, the mail server, payment apis ...) and remove dummy services
3837
systeminfohealth.Add(new SystemInfoHealthEntryDto("NETEVENT Server", string.Empty, true));
@@ -42,5 +41,10 @@ public Task<GetSystemInfoResponse> Handle(GetSystemInfoRequest request, Cancella
4241

4342
return Task.FromResult(new GetSystemInfoResponse(systeminfo));
4443
}
44+
45+
private static SystemInfoVersionEntryDto CreateSystemInfoVersionEntryFromEnv(string envName)
46+
{
47+
return new SystemInfoVersionEntryDto(envName, string.IsNullOrEmpty(Environment.GetEnvironmentVariable(envName)) ? "dev" : Environment.GetEnvironmentVariable(envName));
48+
}
4549
}
4650
}

0 commit comments

Comments
 (0)