/**
 * 仪表板统计快照仓储接口
 */
export const DASHBOARD_STATS_SNAPSHOT_REPOSITORY = Symbol(
  'DASHBOARD_STATS_SNAPSHOT_REPOSITORY',
);

export interface DashboardStatsSnapshotData {
  id?: bigint;
  snapshotDate: Date;
  totalPlantingCount: number;
  totalPlantingChange: number;
  activeUserCount: number;
  activeUserChange: number;
  provinceCompanyCount: number;
  provinceCompanyChange: number;
  cityCompanyCount: number;
  cityCompanyChange: number;
  regionDistribution?: Record<string, unknown>;
  createdAt?: Date;
  updatedAt?: Date;
}

export interface IDashboardStatsSnapshotRepository {
  /**
   * 保存或更新快照
   */
  save(snapshot: DashboardStatsSnapshotData): Promise<DashboardStatsSnapshotData>;

  /**
   * 根据ID查找
   */
  findById(id: bigint): Promise<DashboardStatsSnapshotData | null>;

  /**
   * 根据日期查找
   */
  findByDate(date: Date): Promise<DashboardStatsSnapshotData | null>;

  /**
   * 获取最新的快照
   */
  findLatest(): Promise<DashboardStatsSnapshotData | null>;

  /**
   * 获取日期范围内的快照
   */
  findByDateRange(
    startDate: Date,
    endDate: Date,
  ): Promise<DashboardStatsSnapshotData[]>;

  /**
   * 删除指定日期之前的快照
   */
  deleteBeforeDate(date: Date): Promise<number>;
}
