import { IsOptional, IsString, IsNumber, Min, Max } from 'class-validator';
import { Type } from 'class-transformer';
import { ApiPropertyOptional } from '@nestjs/swagger';

export class GetTrendsDto {
    @ApiPropertyOptional({ description: 'Filter by category' })
    @IsOptional()
    @IsString()
    category?: string;

    @ApiPropertyOptional({ description: 'Filter by source' })
    @IsOptional()
    @IsString()
    source?: string;

    @ApiPropertyOptional({ default: 50, minimum: 1, maximum: 200 })
    @IsOptional()
    @Type(() => Number)
    @IsNumber()
    @Min(1)
    @Max(200)
    limit?: number = 50;

    @ApiPropertyOptional({ default: 0, description: 'Minimum trend score (0-100)' })
    @IsOptional()
    @Type(() => Number)
    @IsNumber()
    @Min(0)
    @Max(100)
    minScore?: number = 0;

    @ApiPropertyOptional({ description: 'Search keyword in title' })
    @IsOptional()
    @IsString()
    q?: string;

    @ApiPropertyOptional({
        description: 'Max age in hours',
        default: 24,
    })
    @IsOptional()
    @Type(() => Number)
    @IsNumber()
    maxAgeHours?: number = 24;
}

export class CollectNowDto {
    @ApiPropertyOptional({
        description: 'Specific source to collect from',
        enum: ['google-trends', 'reddit', 'hackernews', 'rss', 'newsapi'],
    })
    @IsOptional()
    @IsString()
    source?: string;
}
