namespace ZB.MOM.WW.ScadaBridge.KpiHistory;
///
/// Configuration for the KPI History component. Bound from the
/// ScadaBridge:KpiHistory section of appsettings.json. Defaults
/// reflect the design: a 60-second sampling cadence for the point-in-time
/// Notification Outbox / Site Call Audit KPI snapshots, a 90-day central
/// retention window with a daily purge sweep, and a 200-point default ceiling
/// on the series returned to the Central UI trend charts.
///
public sealed class KpiHistoryOptions
{
///
/// How often the recorder captures a KPI sample row (default 60 s). Must be
/// strictly positive.
///
public TimeSpan SampleInterval { get; set; } = TimeSpan.FromSeconds(60);
///
/// Central retention window in days for recorded KPI samples (default 90,
/// range [1, 3650]). Rows older than this are dropped by the purge
/// sweep.
///
public int RetentionDays { get; set; } = 90;
///
/// How often the purge sweep drops expired sample rows (default 1 day). Must
/// be strictly positive.
///
public TimeSpan PurgeInterval { get; set; } = TimeSpan.FromDays(1);
///
/// Default ceiling on the number of points returned in a single trend series
/// query when the caller does not specify one (default 200, range
/// [2, 5000]). At least two points are required to draw a line.
///
public int DefaultMaxSeriesPoints { get; set; } = 200;
///
/// How often the recorder folds the trailing raw KpiSample rows into the
/// hourly KpiRollupHourly table (default 1 hour). Must be strictly
/// positive. Each tick re-folds the trailing
/// hours via an idempotent upsert, so a tick
/// missed during a singleton-failover handover self-heals on the next fold.
///
public TimeSpan RollupInterval { get; set; } = TimeSpan.FromHours(1);
///
/// How many trailing whole hours each rollup fold re-processes (default 3,
/// range [1, 168]). Folding a lookback window rather than just the last
/// hour lets an idempotent re-fold recover the one or more complete hours a
/// missed/failover tick skipped. Never includes the in-progress hour (the fold's
/// upper bound is the current hour start, exclusive).
///
public int RollupLookbackHours { get; set; } = 3;
///
/// Central retention window in days for the hourly rollup rows (default 365,
/// range [1, 3650]). Rollups outlive raw samples so long-range trend
/// charts have data after raw KpiSample rows are purged; the validator
/// therefore requires RollupRetentionDays >=
/// so a window never falls into a hole where raw is purged but no rollup was
/// written. Dropped by the rollup purge sweep.
///
public int RollupRetentionDays { get; set; } = 365;
///
/// Query-routing boundary in hours (default 168 = 7 days, minimum 24). Trend
/// queries whose window is <= this width read raw KpiSample rows
/// (preserving intra-minute detail); wider windows read the pre-aggregated
/// hourly rollups. Consumed by the Central UI query service's range routing.
///
public int RollupThresholdHours { get; set; } = 168;
}