feat(site-call-audit): additive TrackedOperationId query filter for ?correlationId= deep links

Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
Joseph Doherty
2026-09-06 11:00:03 -04:00
parent 5497ffd181
commit 95773aa9fd
6 changed files with 98 additions and 3 deletions
@@ -294,6 +294,12 @@ WHERE TrackedOperationId = @Id
var fromUtc = filter.FromUtc;
var toUtc = filter.ToUtc;
var stuckCutoff = filter.StuckCutoffUtc;
// TrackedOperationId is a varchar(36) column holding the "D"-format GUID
// string (see SiteCallEntityTypeConfiguration), so the exact-match filter
// is compared as a string — same shape as the @AfterId cursor below. A
// uniqueidentifier parameter would make SQL Server convert the COLUMN side
// (higher type precedence) and lose the PK seek.
var trackedOperationIdString = filter.TrackedOperationId?.ToString("D");
// The stuck predicate (TerminalAtUtc IS NULL AND CreatedAtUtc < cutoff)
// is pushed into SQL here — both columns are plain (no value converter)
@@ -315,6 +321,7 @@ WHERE (@Channel IS NULL OR Channel = @Channel)
AND (@SourceNode IS NULL OR SourceNode = @SourceNode)
AND (@Status IS NULL OR Status = @Status)
AND (@Target IS NULL OR Target = @Target)
AND (@TrackedOperationId IS NULL OR TrackedOperationId = @TrackedOperationId)
AND (@FromUtc IS NULL OR CreatedAtUtc >= @FromUtc)
AND (@ToUtc IS NULL OR CreatedAtUtc <= @ToUtc)
AND (@StuckCutoff IS NULL OR (TerminalAtUtc IS NULL AND CreatedAtUtc < @StuckCutoff))
@@ -338,6 +345,7 @@ OPTION (RECOMPILE);";
Param("@SourceNode", SqlDbType.VarChar, filter.SourceNode),
Param("@Status", SqlDbType.VarChar, filter.Status),
Param("@Target", SqlDbType.VarChar, filter.Target),
Param("@TrackedOperationId", SqlDbType.VarChar, trackedOperationIdString),
Param("@FromUtc", SqlDbType.DateTime2, fromUtc),
Param("@ToUtc", SqlDbType.DateTime2, toUtc),
Param("@StuckCutoff", SqlDbType.DateTime2, stuckCutoff),