feat(auditlog): multi-value AuditLogQueryFilter dimensions

This commit is contained in:
Joseph Doherty
2026-05-21 05:15:51 -04:00
parent b3b02a8cb6
commit 37c7a0e5ac
15 changed files with 196 additions and 77 deletions

View File

@@ -116,25 +116,28 @@ VALUES
var query = _context.Set<AuditEvent>().AsNoTracking();
if (filter.Channel is { } channel)
// Multi-value dimensions: a null OR empty list means "no constraint"
// (the { Count: > 0 } guard prevents an empty list collapsing to a
// WHERE 1=0). A non-empty list translates to a SQL IN (…) via EF Core's
// IReadOnlyList<T>.Contains support — server-side, no client-eval.
if (filter.Channels is { Count: > 0 } channels)
{
query = query.Where(e => e.Channel == channel);
query = query.Where(e => channels.Contains(e.Channel));
}
if (filter.Kind is { } kind)
if (filter.Kinds is { Count: > 0 } kinds)
{
query = query.Where(e => e.Kind == kind);
query = query.Where(e => kinds.Contains(e.Kind));
}
if (filter.Status is { } status)
if (filter.Statuses is { Count: > 0 } statuses)
{
query = query.Where(e => e.Status == status);
query = query.Where(e => statuses.Contains(e.Status));
}
if (!string.IsNullOrEmpty(filter.SourceSiteId))
if (filter.SourceSiteIds is { Count: > 0 } sourceSiteIds)
{
var siteId = filter.SourceSiteId;
query = query.Where(e => e.SourceSiteId == siteId);
query = query.Where(e => e.SourceSiteId != null && sourceSiteIds.Contains(e.SourceSiteId));
}
if (!string.IsNullOrEmpty(filter.Target))