From 783fb2e0f5606059d49e2603a412f6af9a26d294 Mon Sep 17 00:00:00 2001 From: Caspervw Date: Tue, 9 Dec 2025 15:36:39 +0100 Subject: [PATCH] Another float8 to prevent query-crash --- features/latency2.feature | 15 +++++++++++++++ internal/signaling/stores/postgres.go | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/features/latency2.feature b/features/latency2.feature index d8c20df..34f8b07 100644 --- a/features/latency2.feature +++ b/features/latency2.feature @@ -4,6 +4,21 @@ Feature: Geo-based latency2 estimates Given the "signaling" backend is running And the "testproxy" backend is running + Scenario: latency2 is computed using peer geo persisted on connect + Given "red" is connected as "1u8fw4aph5ypt" with lat,lon as 10,20 and ready for game "323e4567-e89b-12d3-a456-426614174000" + And "yellow" is connected as "h5yzwyizlwao" with lat,lon as 30,40 and ready for game "323e4567-e89b-12d3-a456-426614174000" + And "red,yellow" are joined in a public lobby + And "blue" is connected as "3t3cfgcqup9e" with lat,lon as 50,60 and ready for game "323e4567-e89b-12d3-a456-426614174000" + + When "blue" requests lobbies with: + """json + {} + """ + + Then "blue" should have received only these lobbies: + | code | latency2 | + | 19yrzmetd2bn7 | 69 | + Scenario: latency2 is computed from requester to lobby peers Given these lobbies exist: | code | game | peers | public | diff --git a/internal/signaling/stores/postgres.go b/internal/signaling/stores/postgres.go index bbae3b4..e552314 100644 --- a/internal/signaling/stores/postgres.go +++ b/internal/signaling/stores/postgres.go @@ -464,7 +464,7 @@ func (s *PostgresStore) UpdatePeerGeo(ctx context.Context, peerID string, lat, l UPDATE peers SET geo = CASE - WHEN $1 IS NOT NULL AND $2 IS NOT NULL THEN ll_to_earth($1::float8, $2::float8) + WHEN $1::float8 IS NOT NULL AND $2::float8 IS NOT NULL THEN ll_to_earth($1::float8, $2::float8) ELSE NULL END, updated_at = $3