Files
goodgo-platform/apps
Ho Ngoc Hai aed173adca perf(analytics): collapse 6x POI COUNT queries into single GROUP BY (GOO-222)
Replace six sequential prisma.pOI.count() calls in countPOIs() with a
single raw SQL GROUP BY query, cutting DB round-trips from 6 to 1 per
neighborhood score calculation.

- Replace Promise.all + pOI.count loop with prisma.$queryRaw GROUP BY type
- Aggregate per-type counts into category totals client-side via CATEGORY_POI_TYPES map
- Zero-fill missing types preserves existing response shape and callers unchanged
- Update unit tests: mock $queryRaw instead of pOI.count; assert exactly
  1 DB call per calculateAndSave invocation (new assertion per acceptance criteria)

Co-Authored-By: Paperclip <noreply@paperclip.ing>
2026-04-24 12:13:03 +07:00
..