From ae52081d7dcc8784152576a9843529f693049e4c Mon Sep 17 00:00:00 2001 From: Ho Ngoc Hai Date: Thu, 16 Apr 2026 04:27:02 +0700 Subject: [PATCH] fix(listings): remove hardcoded (0,0) geo fallbacks in listing-read queries The findByIdWithProperty and searchListings read queries used `?? { latitude: 0, longitude: 0 }` fallbacks after PostGIS coordinate extraction. Since the Property.location column is NOT NULL, these fallbacks silently masked potential data issues. Replaced with non-null assertions since geo data is guaranteed to exist for valid properties. Co-Authored-By: Paperclip --- .../infrastructure/repositories/listing-read.queries.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/apps/api/src/modules/listings/infrastructure/repositories/listing-read.queries.ts b/apps/api/src/modules/listings/infrastructure/repositories/listing-read.queries.ts index c12e512..badd6fd 100644 --- a/apps/api/src/modules/listings/infrastructure/repositories/listing-read.queries.ts +++ b/apps/api/src/modules/listings/infrastructure/repositories/listing-read.queries.ts @@ -31,7 +31,8 @@ export async function findByIdWithProperty( WHERE "id" = ${listing.property.id} LIMIT 1 `; - const geo = geoRows[0] ?? { latitude: 0, longitude: 0 }; + // location is NOT NULL in the database — geo extraction always succeeds for existing properties + const geo = geoRows[0]!; return { id: listing.id, @@ -147,7 +148,8 @@ export async function searchListings( return { data: data.map((listing) => { - const geo = geoMap.get(listing.property.id) ?? { latitude: 0, longitude: 0 }; + // location is NOT NULL — every property in the result set has geo data + const geo = geoMap.get(listing.property.id)!; return { id: listing.id, status: listing.status,