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

export class DepartmentStatsDto {
  @ApiProperty({
    description: 'Department code',
    example: 'DEPT_001',
  })
  departmentCode: string;

  @ApiProperty({
    description: 'Department name',
    example: 'Finance Department',
  })
  departmentName: string;

  @ApiProperty({
    description: 'Total number of applicants',
    example: 150,
  })
  totalApplicants: number;

  @ApiProperty({
    description: 'Total number of credentials issued',
    example: 145,
  })
  totalCredentialsIssued: number;

  @ApiProperty({
    description: 'Whether the department is active',
    example: true,
  })
  isActive: boolean;

  @ApiProperty({
    description: 'Department creation timestamp',
    example: '2024-01-15T10:30:00Z',
  })
  createdAt: Date;

  @ApiProperty({
    description: 'Department last update timestamp',
    example: '2024-01-15T10:30:00Z',
  })
  updatedAt: Date;

  @ApiProperty({
    description: 'Timestamp of last webhook event',
    example: '2024-01-20T14:00:00Z',
    required: false,
  })
  lastWebhookAt?: Date;

  @ApiProperty({
    description: 'Percentage of credentials issued vs applicants',
    example: 96.67,
  })
  issueRate?: number;

  constructor() {
    if (this.totalApplicants > 0) {
      this.issueRate = (this.totalCredentialsIssued / this.totalApplicants) * 100;
    }
  }
}
