refactor(adminui): delete the dead LoadTagsForEquipmentAsync surface (R04 S4)

v3 retired the equipment-Tag binding; IUnsTreeService.LoadTagsForEquipmentAsync
always returned empty, had no production caller, and EquipmentTagRow plus the
always-zero tagCounts / EquipmentRow.TagCount plumbing existed only to feed it.
All removed; the equipment badge count (virtual tags) is unchanged.

Refs #745
Claude-Session: https://claude.ai/code/session_01Ub9hGmYLQvn9XETzw7CMsT
This commit is contained in:
Joseph Doherty
2026-10-22 17:54:53 -04:00
parent a4cdedc31c
commit 4cfa369354
7 changed files with 12 additions and 64 deletions
@@ -2,11 +2,6 @@ using ZB.MOM.WW.OtOpcUa.Configuration.Enums;
namespace ZB.MOM.WW.OtOpcUa.AdminUI.Uns; namespace ZB.MOM.WW.OtOpcUa.AdminUI.Uns;
/// <summary>A tag row for the equipment page's Tags tab table — display columns plus the id used to
/// open the edit modal. RowVersion is re-read fresh on delete (matching the tree's delete path).</summary>
public sealed record EquipmentTagRow(
string TagId, string Name, string DriverInstanceId, string DataType, TagAccessLevel AccessLevel);
/// <summary>A virtual-tag row for the equipment page's Virtual Tags tab table.</summary> /// <summary>A virtual-tag row for the equipment page's Virtual Tags tab table.</summary>
public sealed record EquipmentVirtualTagRow(string VirtualTagId, string Name, string DataType, string ScriptId, bool Enabled); public sealed record EquipmentVirtualTagRow(string VirtualTagId, string Name, string DataType, string ScriptId, bool Enabled);
@@ -117,17 +117,6 @@ public interface IUnsTreeService
/// <returns>The enterprise root nodes, each populated down to equipment.</returns> /// <returns>The enterprise root nodes, each populated down to equipment.</returns>
Task<IReadOnlyList<UnsNode>> LoadStructureAsync(CancellationToken ct = default); Task<IReadOnlyList<UnsNode>> LoadStructureAsync(CancellationToken ct = default);
/// <summary>
/// Loads the driver tags bound to a single equipment as flat row projections for the equipment
/// page's Tags tab table, ordered by Name. Each row carries the display columns plus the
/// <c>TagId</c> the table uses to open the edit modal. Reads untracked. Returns an empty list when
/// the equipment has no tags.
/// </summary>
/// <param name="equipmentId">The equipment whose tags to load.</param>
/// <param name="ct">A token to cancel the load.</param>
/// <returns>The equipment's tag rows ordered by Name; empty if it has none.</returns>
Task<IReadOnlyList<EquipmentTagRow>> LoadTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default);
/// <summary> /// <summary>
/// Loads the virtual tags scoped to a single equipment as flat row projections for the equipment /// Loads the virtual tags scoped to a single equipment as flat row projections for the equipment
/// page's Virtual Tags tab table, ordered by Name. Each row carries the display columns plus the /// page's Virtual Tags tab table, ordered by Name. Each row carries the display columns plus the
@@ -75,13 +75,13 @@ public readonly record struct AreaRow(string UnsAreaId, string ClusterId, string
/// <summary>Flat structural row describing a UNS line and its owning area.</summary> /// <summary>Flat structural row describing a UNS line and its owning area.</summary>
public readonly record struct LineRow(string UnsLineId, string UnsAreaId, string Name); public readonly record struct LineRow(string UnsLineId, string UnsAreaId, string Name);
/// <summary>Flat structural row describing an equipment node, its owning line and its tag/virtual-tag counts.</summary> /// <summary>Flat structural row describing an equipment node, its owning line and its virtual-tag count.
/// (The driver-tag count was retired with the v3 equipment↔Tag binding; it was always zero.)</summary>
public readonly record struct EquipmentRow( public readonly record struct EquipmentRow(
string EquipmentId, string EquipmentId,
string UnsLineId, string UnsLineId,
string MachineCode, string MachineCode,
string Name, string Name,
int TagCount,
int VirtualTagCount); int VirtualTagCount);
/// <summary> /// <summary>
@@ -237,7 +237,7 @@ public static class UnsTreeAssembly
private static UnsNode BuildEquipment(EquipmentRow equipment, string clusterId) private static UnsNode BuildEquipment(EquipmentRow equipment, string clusterId)
{ {
var childCount = equipment.TagCount + equipment.VirtualTagCount; var childCount = equipment.VirtualTagCount;
return new UnsNode return new UnsNode
{ {
Kind = UnsNodeKind.Equipment, Kind = UnsNodeKind.Equipment,
@@ -61,11 +61,6 @@ public sealed class UnsTreeService(
}) })
.ToListAsync(ct); .ToListAsync(ct);
// Per-equipment driver-tag counts: the equipment↔Tag binding was retired in v3
// (Tag is now Raw-only; authoring moved to the Raw tree in Batch 2/3). No binding
// exists to count against, so every equipment reports zero driver tags.
var tagCounts = new Dictionary<string, int>(StringComparer.Ordinal);
// Per-equipment virtual-tag counts (virtual tags with no equipment are excluded). // Per-equipment virtual-tag counts (virtual tags with no equipment are excluded).
var vtagCounts = (await db.VirtualTags var vtagCounts = (await db.VirtualTags
.AsNoTracking() .AsNoTracking()
@@ -81,21 +76,12 @@ public sealed class UnsTreeService(
e.UnsLineId, e.UnsLineId,
e.MachineCode, e.MachineCode,
e.Name, e.Name,
tagCounts.GetValueOrDefault(e.EquipmentId),
vtagCounts.GetValueOrDefault(e.EquipmentId))) vtagCounts.GetValueOrDefault(e.EquipmentId)))
.ToList(); .ToList();
return UnsTreeAssembly.Build(clusters, areas, lines, equipment); return UnsTreeAssembly.Build(clusters, areas, lines, equipment);
} }
/// <inheritdoc />
public Task<IReadOnlyList<EquipmentTagRow>> LoadTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default)
{
// The equipment↔Tag binding was retired in v3 (Tag is now Raw-only; authoring moved to
// the Raw tree in Batch 2/3). No equipment-bound tags exist to list.
return Task.FromResult<IReadOnlyList<EquipmentTagRow>>(Array.Empty<EquipmentTagRow>());
}
/// <inheritdoc /> /// <inheritdoc />
public async Task<IReadOnlyList<EquipmentVirtualTagRow>> LoadVirtualTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default) public async Task<IReadOnlyList<EquipmentVirtualTagRow>> LoadVirtualTagsForEquipmentAsync(string equipmentId, CancellationToken ct = default)
{ {
@@ -37,7 +37,7 @@ public sealed class UnsTreeAssemblyTests
var clusters = new[] { new ClusterRow("c1", "zb", "SiteA", "Alpha") }; var clusters = new[] { new ClusterRow("c1", "zb", "SiteA", "Alpha") };
var areas = new[] { new AreaRow("a1", "c1", "AreaOne") }; var areas = new[] { new AreaRow("a1", "c1", "AreaOne") };
var lines = new[] { new LineRow("l1", "a1", "LineOne") }; var lines = new[] { new LineRow("l1", "a1", "LineOne") };
var equipment = new[] { new EquipmentRow("e1", "l1", "MC-1", "EquipOne", 0, 0) }; var equipment = new[] { new EquipmentRow("e1", "l1", "MC-1", "EquipOne", 0) };
var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment);
@@ -75,8 +75,8 @@ public sealed class UnsTreeAssemblyTests
var lines = new[] { new LineRow("l1", "a1", "LineOne") }; var lines = new[] { new LineRow("l1", "a1", "LineOne") };
var equipment = new[] var equipment = new[]
{ {
new EquipmentRow("e1", "l1", "MC-1", "WithChildren", 2, 1), new EquipmentRow("e1", "l1", "MC-1", "WithChildren", 3),
new EquipmentRow("e2", "l1", "MC-2", "Empty", 0, 0), new EquipmentRow("e2", "l1", "MC-2", "Empty", 0),
}; };
var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment);
@@ -84,7 +84,7 @@ public sealed class UnsTreeAssemblyTests
// Equipment is a tree leaf that links to its own detail page, so it never carries an // Equipment is a tree leaf that links to its own detail page, so it never carries an
// expander — HasLazyChildren is always false regardless of its tag/virtual-tag count. // expander — HasLazyChildren is always false regardless of its tag/virtual-tag count.
// The ChildCount badge still reflects tags + virtual tags. // The ChildCount badge reflects its virtual tags.
var withChildren = line.Children.Single(e => e.Key == "eq:e1"); var withChildren = line.Children.Single(e => e.Key == "eq:e1");
withChildren.ChildCount.ShouldBe(3); withChildren.ChildCount.ShouldBe(3);
withChildren.HasLazyChildren.ShouldBeFalse(); withChildren.HasLazyChildren.ShouldBeFalse();
@@ -145,8 +145,8 @@ public sealed class UnsTreeAssemblyTests
}; };
var equipment = new[] var equipment = new[]
{ {
new EquipmentRow("e2", "l1", "MC-2", "EquipB", 0, 0), new EquipmentRow("e2", "l1", "MC-2", "EquipB", 0),
new EquipmentRow("e1", "l1", "MC-1", "EquipA", 0, 0), new EquipmentRow("e1", "l1", "MC-1", "EquipA", 0),
}; };
var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment); var tree = UnsTreeAssembly.Build(clusters, areas, lines, equipment);
@@ -14,16 +14,8 @@ public sealed class UnsTreeServiceEquipmentChildRowsTests
return new UnsTreeService(UnsTreeTestDb.Factory(dbName)); return new UnsTreeService(UnsTreeTestDb.Factory(dbName));
} }
// v3 Batch-1: the equipment↔Tag binding was retired (Tag is Raw-only; authoring moved to the Raw // v3 Batch-1 retired the equipment↔Tag binding; the always-empty LoadTagsForEquipmentAsync stub and
// tree in Batch 2). LoadTagsForEquipmentAsync is a stub that always returns empty — no equipment // its EquipmentTagRow were deleted (R04 S4). Equipment tags are UnsTagReference rows now.
// has bound driver tags to list. The former in-name-order / EquipmentId-scoping assertions moved
// with the authoring surface to the Batch-2 Raw-tree tests.
[Fact]
public async Task LoadTagsForEquipment_returns_empty_stub()
{
var rows = await SeededService().LoadTagsForEquipmentAsync(UnsTreeTestDb.SeededEquipmentId);
rows.ShouldBeEmpty();
}
[Fact] [Fact]
public async Task LoadVirtualTagsForEquipment_returns_vtags_in_name_order() public async Task LoadVirtualTagsForEquipment_returns_vtags_in_name_order()
@@ -34,8 +26,4 @@ public sealed class UnsTreeServiceEquipmentChildRowsTests
rows[0].Name.ShouldBe("computed"); rows[0].Name.ShouldBe("computed");
rows[0].DataType.ShouldBe("Double"); rows[0].DataType.ShouldBe("Double");
} }
[Fact]
public async Task LoadTagsForEquipment_empty_for_unknown_equipment()
=> (await SeededService().LoadTagsForEquipmentAsync("EQ-NONE")).ShouldBeEmpty();
} }
@@ -12,7 +12,7 @@ namespace ZB.MOM.WW.OtOpcUa.AdminUI.Tests.Uns;
/// <c>FolderPath</c>), the <c>Namespace</c>/<c>NamespaceKind</c> entities were deleted, and tag /// <c>FolderPath</c>), the <c>Namespace</c>/<c>NamespaceKind</c> entities were deleted, and tag
/// authoring moved to the Raw tree (<c>/raw</c>) in Batch 2. So <see cref="UnsTreeService"/>'s /// authoring moved to the Raw tree (<c>/raw</c>) in Batch 2. So <see cref="UnsTreeService"/>'s
/// <c>CreateTagAsync</c> / <c>UpdateTagAsync</c> now return a uniform Batch-1 refusal, and /// <c>CreateTagAsync</c> / <c>UpdateTagAsync</c> now return a uniform Batch-1 refusal, and
/// <c>LoadTagsForEquipmentAsync</c> / <c>LoadTagDriversForEquipmentAsync</c> return empty. The tests /// <c>LoadTagDriversForEquipmentAsync</c> returns empty. The tests
/// below assert that stub contract (preserving the intent of the old CRUD-guard / driver-loader /// below assert that stub contract (preserving the intent of the old CRUD-guard / driver-loader
/// tests) plus the still-live <c>DeleteTagAsync</c> path (which continues to remove a raw Tag row). /// tests) plus the still-live <c>DeleteTagAsync</c> path (which continues to remove a raw Tag row).
/// </summary> /// </summary>
@@ -153,16 +153,6 @@ public sealed class UnsTreeServiceTagTests
// ----- Per-equipment loaders: retired → empty ----- // ----- Per-equipment loaders: retired → empty -----
/// <summary>The per-equipment tag list is retired (Tag is Raw-only) → always empty.</summary>
[Fact]
public async Task LoadTagsForEquipment_returns_empty()
{
var (service, dbName) = Fresh();
SeedHierarchy(dbName);
(await service.LoadTagsForEquipmentAsync("EQ-1")).ShouldBeEmpty();
}
/// <summary>The per-equipment candidate-driver loader is retired (equipment↔driver binding gone) → always empty.</summary> /// <summary>The per-equipment candidate-driver loader is retired (equipment↔driver binding gone) → always empty.</summary>
[Fact] [Fact]
public async Task LoadTagDriversForEquipment_returns_empty() public async Task LoadTagDriversForEquipment_returns_empty()