using ZB.MOM.WW.ScadaBridge.Commons.Entities.Kpi;
using ZB.MOM.WW.ScadaBridge.Commons.Types.Kpi;
namespace ZB.MOM.WW.ScadaBridge.Commons.Interfaces.Repositories;
///
/// Data access for the central KPI-history backbone ("KPI History & Trends")
/// — the tall / EAV KpiSample table in central MS SQL. Backs the recorder
/// singleton's bulk write, the bucketed query path that feeds the reusable trend
/// chart, and the retention purge. Implementation lives in the Configuration
/// Database component.
///
public interface IKpiHistoryRepository
{
///
/// Bulk-inserts a batch of captured samples (one sampling pass across all
/// registered sources).
///
/// The samples to record.
/// Cancellation token.
/// A task that represents the asynchronous write.
Task RecordSamplesAsync(IReadOnlyCollection samples, CancellationToken cancellationToken = default);
///
/// Returns the raw points for one series in [fromUtc, toUtc], ordered by
/// ascending.
///
/// Source identifier — a value from .
/// Metric name from the source's catalog.
/// Scope discriminator — a value from .
/// Scope qualifier (site id / node name); null for the Global scope.
/// Inclusive lower bound of the time window (UTC).
/// Inclusive upper bound of the time window (UTC).
/// Cancellation token.
///
/// A task resolving to the raw series points in ascending capture order; empty when
/// the series has no samples in the window.
///
Task> GetRawSeriesAsync(
string source, string metric, string scope, string? scopeKey,
DateTime fromUtc, DateTime toUtc, CancellationToken cancellationToken = default);
///
/// Bulk-deletes rows whose is strictly older
/// than (retention purge). Implementations slice the
/// purge into time-windowed DELETE batches so a large catch-up (e.g. after an
/// outage) never runs as a single lock/log-heavy transaction (arch-review 04, P4).
///
/// UTC cut-off; rows captured before this instant are deleted.
/// Cancellation token.
/// A task resolving to the number of rows deleted.
Task PurgeOlderThanAsync(DateTime before, CancellationToken cancellationToken = default);
}