import { ApiProperty } from '@nestjs/swagger';

export class OnlineHistoryDataPointDto {
  @ApiProperty({ description: '时间戳 (ISO 8601)', example: '2025-01-01T12:00:00.000Z' })
  timestamp: string;

  @ApiProperty({ description: '在线人数', example: 1520 })
  onlineCount: number;

  @ApiProperty({ description: '在线判定时间窗口（秒）', example: 180 })
  windowSeconds: number;
}

export class OnlineHistorySummaryDto {
  @ApiProperty({ description: '最大在线人数', example: 2000 })
  maxOnline: number;

  @ApiProperty({ description: '最小在线人数', example: 500 })
  minOnline: number;

  @ApiProperty({ description: '平均在线人数', example: 1200 })
  avgOnline: number;

  @ApiProperty({
    description: '最大在线时的时间戳',
    example: '2025-01-01T20:00:00.000Z',
    nullable: true,
  })
  maxTimestamp: string | null;

  @ApiProperty({
    description: '最小在线时的时间戳',
    example: '2025-01-01T04:00:00.000Z',
    nullable: true,
  })
  minTimestamp: string | null;
}

export class OnlineHistoryResponseDto {
  @ApiProperty({
    description: '历史数据点列表',
    type: [OnlineHistoryDataPointDto],
  })
  data: OnlineHistoryDataPointDto[];

  @ApiProperty({
    description: '数据聚合间隔',
    enum: ['1m', '5m', '1h'],
    example: '5m',
  })
  interval: string;

  @ApiProperty({ description: '查询开始时间', example: '2025-01-01T00:00:00.000Z' })
  startTime: string;

  @ApiProperty({ description: '查询结束时间', example: '2025-01-01T23:59:59.000Z' })
  endTime: string;

  @ApiProperty({ description: '数据点总数', example: 288 })
  total: number;

  @ApiProperty({ description: '汇总统计', type: OnlineHistorySummaryDto })
  summary: OnlineHistorySummaryDto;
}
