feat(analytics): add GET /analytics/price-movers endpoint
Top tăng/giảm giá theo district cho Home dashboard. Compares avg listing prices between current and previous time windows, filters by min sample size (10), caches for 30 min. TEC-3053 Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
|
||||
import { Type } from 'class-transformer';
|
||||
import { IsIn, IsInt, IsOptional, Max, Min } from 'class-validator';
|
||||
|
||||
export class GetPriceMoversDto {
|
||||
@ApiProperty({
|
||||
description: 'Price movement direction',
|
||||
enum: ['up', 'down'],
|
||||
example: 'up',
|
||||
})
|
||||
@IsIn(['up', 'down'])
|
||||
direction: 'up' | 'down' = 'up';
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Look-back period',
|
||||
enum: ['7d', '14d', '30d'],
|
||||
default: '7d',
|
||||
example: '7d',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsIn(['7d', '14d', '30d'])
|
||||
period: string = '7d';
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Maximum number of results to return',
|
||||
minimum: 1,
|
||||
maximum: 20,
|
||||
default: 5,
|
||||
example: 5,
|
||||
})
|
||||
@IsOptional()
|
||||
@Type(() => Number)
|
||||
@IsInt()
|
||||
@Min(1)
|
||||
@Max(20)
|
||||
limit: number = 5;
|
||||
|
||||
@ApiPropertyOptional({
|
||||
description: 'Geographic aggregation level (currently only "district" is supported)',
|
||||
enum: ['district'],
|
||||
default: 'district',
|
||||
example: 'district',
|
||||
})
|
||||
@IsOptional()
|
||||
@IsIn(['district'])
|
||||
level: 'district' = 'district';
|
||||
}
|
||||
Reference in New Issue
Block a user