Skip to content

Commit 0ad0e3f

Browse files
feat: Optimize map health checks in Manage Maps view for improved performance and clarity
1 parent 4a5b7d8 commit 0ad0e3f

1 file changed

Lines changed: 11 additions & 15 deletions

File tree

src/XtremeIdiots.Portal.Web/Views/MapManager/Manage.cshtml

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@
6565
var mapsByName = Model.Maps.ToDictionary(m => m.MapName, StringComparer.OrdinalIgnoreCase);
6666
var serverMapNames = Model.ServerMaps.Select(m => m.Name).ToHashSet(StringComparer.OrdinalIgnoreCase);
6767
var serverMapsByName = Model.ServerMaps.ToDictionary(m => m.Name, StringComparer.OrdinalIgnoreCase);
68+
69+
var activeRotMaps = Model.ActiveRotation?.MapRotationMaps ?? [];
70+
var missingFromHost = activeRotMaps.Count(rm =>
71+
{
72+
var mn = mapsById.TryGetValue(rm.MapId, out var m) ? m.MapName : null;
73+
return mn != null && !serverMapNames.Contains(mn);
74+
});
75+
var problematicCount = activeRotMaps.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapStatus == MapHealthStatus.Problematic);
76+
var blacklistedCount = activeRotMaps.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapStatus == MapHealthStatus.Blacklisted);
77+
var sortedRotMaps = Model.ActiveRotation?.MapRotationMaps?.OrderBy(m => m.SortOrder).ToList() ?? [];
6878
}
6979

7080
@* Tab 1: Current Rotation *@
@@ -86,16 +96,6 @@
8696
· @(Model.ActiveRotation.MapRotationMaps?.Count ?? 0) maps · Version @Model.ActiveRotation.Version
8797
</small>
8898
</div>
89-
@{
90-
var rotMapsForHealth = Model.ActiveRotation.MapRotationMaps ?? [];
91-
var missingFromHost = rotMapsForHealth.Count(rm =>
92-
{
93-
var mapName = mapsById.TryGetValue(rm.MapId, out var m) ? m.MapName : null;
94-
return mapName != null && !serverMapNames.Contains(mapName);
95-
});
96-
var problematicCount = rotMapsForHealth.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapStatus == MapHealthStatus.Problematic);
97-
var blacklistedCount = rotMapsForHealth.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapStatus == MapHealthStatus.Blacklisted);
98-
}
9999
@if (missingFromHost > 0 || problematicCount > 0 || blacklistedCount > 0)
100100
{
101101
<div class="alert alert-warning py-2 mb-3">
@@ -127,7 +127,6 @@
127127
</tr>
128128
</thead>
129129
<tbody>
130-
@{ var sortedRotMaps = Model.ActiveRotation.MapRotationMaps?.OrderBy(m => m.SortOrder).ToList() ?? []; }
131130
@for (var i = 0; i < sortedRotMaps.Count; i++)
132131
{
133132
var rotMap = sortedRotMaps[i];
@@ -370,10 +369,7 @@
370369
@{
371370
var rotMaps = rotation?.MapRotationMaps ?? [];
372371
var healthIssues = rotMaps.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapStatus != MapHealthStatus.OK);
373-
var notOnHost = rotMaps.Count(rm => {
374-
var mapName = mapsById.TryGetValue(rm.MapId, out var m) ? m.MapName : null;
375-
return mapName != null && !serverMapNames.Contains(mapName);
376-
});
372+
var notOnHost = rotMaps.Count(rm => mapsById.TryGetValue(rm.MapId, out var m) && m.MapName != null && !serverMapNames.Contains(m.MapName));
377373
var totalWarnings = healthIssues + notOnHost;
378374
}
379375
@if (totalWarnings > 0)

0 commit comments

Comments
 (0)