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

@@ -39,6 +39,10 @@ export const CacheTTL = {
TRENDING_AREAS: 1800, // 30 min
/** Price movers — 30 min TTL, aggregation over two time windows */
PRICE_MOVERS: 1800, // 30 min
/** Market history — 6 hour TTL, time-series data recomputed nightly */
MARKET_HISTORY: 21600, // 6 hours
/** AVM valuation estimate per listing — long TTL, model outputs are stable within a day */
VALUATION_LISTING: 86400, // 24 h
} as const;
export enum CachePrefix {
@@ -58,6 +62,7 @@ export enum CachePrefix {
MARKET_SNAPSHOT = 'cache:analytics:market_snapshot',
TRENDING_AREAS = 'cache:analytics:trending_areas',
PRICE_MOVERS = 'cache:analytics:price_movers',
MARKET_HISTORY = 'cache:analytics:market_history',
}
@Injectable()