Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions features/latency2.feature
Original file line number Diff line number Diff line change
Expand Up @@ -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 |
Expand Down
2 changes: 1 addition & 1 deletion internal/signaling/stores/postgres.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down