feat(analytics): add GET /analytics/market-history endpoint

Time-series endpoint returning monthly/weekly market data points
for the analytics page. Queries MarketIndex aggregated by period
with 6-hour Redis cache. Includes unit tests.

Co-Authored-By: Paperclip <noreply@paperclip.ing>
This commit is contained in:
Ho Ngoc Hai
2026-04-21 02:37:10 +07:00
parent 0651074319
commit f7b0fe6f5d
9 changed files with 297 additions and 0 deletions

View File

@@ -0,0 +1,29 @@
import { ApiProperty, ApiPropertyOptional } from '@nestjs/swagger';
import { PropertyType } from '@prisma/client';
import { IsEnum, IsIn, IsOptional, IsString } from 'class-validator';
export class GetMarketHistoryDto {
@ApiProperty({ description: 'City name', example: 'HCMC' })
@IsString()
city!: string;
@ApiProperty({
description: 'Look-back period (e.g. 12m, 6m, 24m)',
example: '12m',
})
@IsString()
period!: string;
@ApiProperty({
description: 'Time granularity',
enum: ['monthly', 'weekly'],
default: 'monthly',
})
@IsIn(['monthly', 'weekly'])
granularity!: 'monthly' | 'weekly';
@ApiPropertyOptional({ enum: PropertyType, description: 'Property type filter' })
@IsOptional()
@IsEnum(PropertyType)
propertyType?: PropertyType;
}