milergeo added

This commit is contained in:
2026-10-06 12:26:57 +05:30
parent 220e934045
commit 9b94be1f07
10 changed files with 329 additions and 44 deletions

View File

@@ -9,6 +9,8 @@ import (
"strings"
"time"
"doormile/internal/milergeo"
"github.com/redis/go-redis/v9"
"gorm.io/gorm"
)
@@ -159,13 +161,7 @@ func nearbyMilers(rdb *redis.Client) Executor {
if in.RadiusKm <= 0 || in.RadiusKm > nearbyMaxKm {
in.RadiusKm = 5
}
locs, err := rdb.GeoSearchLocation(ctx, "milers:locations", &redis.GeoSearchLocationQuery{
GeoSearchQuery: redis.GeoSearchQuery{
Longitude: *in.Lon, Latitude: *in.Lat,
Radius: in.RadiusKm, RadiusUnit: "km", Sort: "ASC", Count: nearbyMaxCount,
},
WithDist: true,
}).Result()
locs, err := milergeo.Search(ctx, rdb, *in.Lat, *in.Lon, in.RadiusKm, nearbyMaxCount)
if err != nil {
return nil, errors.New("live rider positions are unavailable")
}