소스 검색

Server Summary Fix

James 2 달 전
부모
커밋
f6fd7b6fb9
2개의 변경된 파일22개의 추가작업 그리고 3개의 파일을 삭제
  1. 21 2
      RackPeek.Domain/Resources/Servers/ServerHardwareReport.cs
  2. 1 1
      Shared.Rcl/Commands/Servers/ServerReportCommand.cs

+ 21 - 2
RackPeek.Domain/Resources/Servers/ServerHardwareReport.cs

@@ -1,4 +1,5 @@
 using RackPeek.Domain.Persistence;
+using RackPeek.Domain.Resources.SubResources;
 
 namespace RackPeek.Domain.Resources.Servers;
 
@@ -20,8 +21,25 @@ public record ServerHardwareRow(
     int GpuCount,
     int TotalGpuVramGb,
     string GpuSummary,
-    bool Ipmi
+    bool Ipmi, 
+    IReadOnlyList<Nic> Nics
+)
+{        
+public string NicSummary =>
+string.Join(", ",
+    (Nics ?? [])
+    .SelectMany(n =>
+    {
+        var ports = n.Ports ?? 1;
+        var speed = n.Speed ?? 0;
+        return Enumerable.Repeat(speed, ports);
+    })
+    .GroupBy(speed => speed)
+    .OrderByDescending(g => g.Key)
+    .Select(g => $"{g.Count()}×{g.Key}G")
+    .DefaultIfEmpty("none")
 );
+}
 
 public class ServerHardwareReportUseCase(IResourceCollection repository) : IUseCase
 {
@@ -81,7 +99,8 @@ public class ServerHardwareReportUseCase(IResourceCollection repository) : IUseC
                 gpuCount,
                 totalGpuVram,
                 gpuSummary,
-                server.Ipmi ?? false
+                server.Ipmi ?? false,
+                server.Nics ?? new List<Nic>()
             );
         }).ToList();
 

+ 1 - 1
Shared.Rcl/Commands/Servers/ServerReportCommand.cs

@@ -40,7 +40,7 @@ public class ServerReportCommand(ILogger<ServerReportCommand> logger, IServicePr
                 $"{s.TotalCores}/{s.TotalThreads}",
                 $"{s.RamGb} GB",
                 $"{s.TotalStorageGb} GB (SSD {s.SsdStorageGb} / HDD {s.HddStorageGb})",
-                $"{s.TotalNicPorts}×{s.MaxNicSpeedGb}G",
+                s.NicSummary,
                 s.GpuCount == 0
                     ? "[grey]none[/]"
                     : $"{s.GpuSummary} ({s.TotalGpuVramGb} GB VRAM)",