using System;
namespace FrameworkDAL.CustomCode.GOP.DTOs
{
// ============================================================
// GopReportDTO — Read-only report row DTOs.
// All populated by aggregate SQL in GopReportQB — no N+1.
// No PK / audit fields; these are never persisted.
// ============================================================
/// Per-flow execution summary: counts, success rate, avg duration.
public class GopExecutionSummaryRowDTO
{
public string FlowCode { get; set; } = string.Empty;
public int TotalCount { get; set; }
public int SuccessCount { get; set; }
public int FailureCount { get; set; }
public int RetryCount { get; set; }
public double AvgDurationMs { get; set; }
public long MaxDurationMs { get; set; }
public DateTime? LastRunAt { get; set; }
}
/// Dead-letter queue row with age in days.
public class GopDlqAgingRowDTO
{
public int DlqId { get; set; }
public int ExecutionId { get; set; }
public string FlowCode { get; set; } = string.Empty;
public string? FailedNodeCode { get; set; }
public string? ErrorMessage { get; set; }
public string? FailureCategory { get; set; }
public int RetryCount { get; set; }
public DateTime MovedToDlqAt { get; set; }
public int AgeDays { get; set; }
}
/// Per-qualifier finding/execution frequency across all flows.
public class QualifierFindingFrequencyRowDTO
{
public string QualifierCode { get; set; } = string.Empty;
public string QualifierName { get; set; } = string.Empty;
public string EntityCode { get; set; } = string.Empty;
public int ExecutionCount { get; set; }
public int SuccessCount { get; set; }
public int FailureCount { get; set; }
public DateTime? LastSeenAt { get; set; }
}
/// Per-qualifier node execution timing from TGopExecutionNodeMetrics.
public class QualifierPerformanceRowDTO
{
public string QualifierCode { get; set; } = string.Empty;
public string QualifierName { get; set; } = string.Empty;
public int EvalCount { get; set; }
public double AvgDurationMs { get; set; }
public long MaxDurationMs { get; set; }
public long MinDurationMs { get; set; }
public double SuccessRate { get; set; }
}
///
/// Flow snapshot drift: flows where the latest published snapshot
/// has a different spec aggregate hash than the currently active snapshot.
/// IsDrifted = 1 when a newer unactivated snapshot exists.
///
public class GopDriftRowDTO
{
public int TenantId { get; set; }
public int FlowId { get; set; }
public string FlowCode { get; set; } = string.Empty;
public string FlowName { get; set; } = string.Empty;
// SnapshotVersion is a free-text label the publisher types in (e.g. "v1",
// "v1-e2e-2647"), never a sequential integer — see GopReportQB.GET_FLOW_DRIFT.
public string? ActiveSnapshotVersion { get; set; }
public string? ActiveSpecHash { get; set; }
public string? LatestSnapshotVersion { get; set; }
public string? LatestSpecHash { get; set; }
public bool IsDrifted { get; set; }
public DateTime? LatestPublishedOn { get; set; }
}
///
/// Qualifier coverage by entity/stage/scope:
/// how many qualifiers (total and active) are bound per context.
///
public class QualifierCoverageRowDTO
{
public int TenantId { get; set; }
public string EntityCode { get; set; } = string.Empty;
public byte Stage { get; set; }
public byte Scope { get; set; }
public int TotalQualifiers { get; set; }
public int ActiveQualifiers { get; set; }
public DateTime? LastActivatedOn { get; set; }
}
}