feat(ui): add Node column + filter to AuditLog grid
This commit is contained in:
@@ -140,6 +140,13 @@ VALUES
|
||||
query = query.Where(e => e.SourceSiteId != null && sourceSiteIds.Contains(e.SourceSiteId));
|
||||
}
|
||||
|
||||
// SourceNode filter mirrors SourceSiteIds: a non-empty list translates to
|
||||
// SQL IN (…); NULL SourceNode rows are excluded when the filter is set.
|
||||
if (filter.SourceNodes is { Count: > 0 } sourceNodes)
|
||||
{
|
||||
query = query.Where(e => e.SourceNode != null && sourceNodes.Contains(e.SourceNode));
|
||||
}
|
||||
|
||||
if (!string.IsNullOrEmpty(filter.Target))
|
||||
{
|
||||
var target = filter.Target;
|
||||
@@ -761,6 +768,25 @@ VALUES
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Distinct non-null <c>SourceNode</c> values for the Audit Log page's
|
||||
/// Node filter dropdown. EF Core translates this to
|
||||
/// <c>SELECT DISTINCT SourceNode FROM AuditLog WHERE SourceNode IS NOT NULL ORDER BY SourceNode</c>
|
||||
/// — a single index-less scan, but the column is bounded (one entry per
|
||||
/// node in the cluster, currently <10) and the Central UI caches the
|
||||
/// result for ~60s, so a periodic scan is acceptable.
|
||||
/// </summary>
|
||||
public async Task<IReadOnlyList<string>> GetDistinctSourceNodesAsync(CancellationToken ct = default)
|
||||
{
|
||||
return await _context.Set<AuditEvent>()
|
||||
.AsNoTracking()
|
||||
.Where(e => e.SourceNode != null)
|
||||
.Select(e => e.SourceNode!)
|
||||
.Distinct()
|
||||
.OrderBy(n => n)
|
||||
.ToListAsync(ct);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Splits a <c>STRING_AGG</c> comma-joined value into a distinct, ordered
|
||||
/// list. A null/empty aggregate (a stub node with no rows) yields an empty
|
||||
|
||||
Reference in New Issue
Block a user