Compute nearby-brewery distance in SQL instead of client-side Haversine, and add the spatial index it relies on.

This commit is contained in:
Aaron Po
2026-08-27 02:40:58 -04:00
parent dab7aa2458
commit 7330eabebe
10 changed files with 244 additions and 121 deletions

View File

@@ -32,8 +32,13 @@ public record BreweryDto(
byte[]? RowVersion,
BreweryLocationDto? Location
);
/// <param name="DistanceMetres">
/// The distance, in metres, from a query's origin point, or <see langword="null"/> for queries with no
/// origin point (e.g. <c>GET /api/brewery/locations</c>).
/// </param>
public record SimplifiedBreweryDto(
Guid BreweryPostId,
string BreweryName,
BreweryLocationDto? Location
BreweryLocationDto? Location,
double? DistanceMetres
);

View File

@@ -68,7 +68,8 @@ public static class BreweryDtoMapper
AddressLine2: brewery.Location.AddressLine2,
PostalCode: brewery.Location.PostalCode,
Coordinates: brewery.Location.Coordinates
)
),
DistanceMetres: brewery.Distance?.DistanceMetres
);
}
}