From a87532ff6e3f4bb033bc42a1f55567370cb21cd3 Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Wed, 8 Apr 2026 23:07:00 +0700 Subject: [PATCH] refactor(api): improve cache service and analytics handlers Update cache service with better error handling and analytics query handlers to use consistent caching patterns. Co-Authored-By: Paperclip --- .../get-district-stats/get-district-stats.handler.ts | 2 +- .../queries/get-heatmap/get-heatmap.handler.ts | 2 +- .../get-market-report/get-market-report.handler.ts | 2 +- .../src/modules/shared/infrastructure/cache.service.ts | 9 ++++++++- 4 files changed, 11 insertions(+), 4 deletions(-) diff --git a/apps/api/src/modules/analytics/application/queries/get-district-stats/get-district-stats.handler.ts b/apps/api/src/modules/analytics/application/queries/get-district-stats/get-district-stats.handler.ts index 9049b73..5c91a70 100644 --- a/apps/api/src/modules/analytics/application/queries/get-district-stats/get-district-stats.handler.ts +++ b/apps/api/src/modules/analytics/application/queries/get-district-stats/get-district-stats.handler.ts @@ -30,7 +30,7 @@ export class GetDistrictStatsHandler implements IQueryHandler { const dataPoints = await this.marketIndexRepo.getHeatmap(query.city, query.period); return { city: query.city, period: query.period, dataPoints }; }, - CacheTTL.MARKET_DATA, + CacheTTL.HEATMAP, 'heatmap', ); } diff --git a/apps/api/src/modules/analytics/application/queries/get-market-report/get-market-report.handler.ts b/apps/api/src/modules/analytics/application/queries/get-market-report/get-market-report.handler.ts index 0dedecc..7a9bc38 100644 --- a/apps/api/src/modules/analytics/application/queries/get-market-report/get-market-report.handler.ts +++ b/apps/api/src/modules/analytics/application/queries/get-market-report/get-market-report.handler.ts @@ -34,7 +34,7 @@ export class GetMarketReportHandler implements IQueryHandler