From b0da36a0eb619c5c1b05ea77791c3927a57b4fd3 Mon Sep 17 00:00:00 2001 From: Mike Date: Mon, 25 May 2020 15:37:54 +0300 Subject: [PATCH] Expose last user relationship update time when listing friends. (#431) --- CHANGELOG.md | 1 + go.mod | 2 +- go.sum | 4 +- server/core_friend.go | 6 +- .../github.com/blevesearch/bleve/geo/geo.go | 2 +- .../heroiclabs/nakama-common/api/api.pb.go | 477 +++++++++--------- .../heroiclabs/nakama-common/api/api.proto | 2 + vendor/modules.txt | 2 +- 8 files changed, 255 insertions(+), 241 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b5610fd17..654f1c443 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -15,6 +15,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - New Lua runtime function to print a log message at debug level. - Lua runtime accounts get operations now return Facebook Instant Game IDs. - Runtime account get operations now return account disable time if available. +- Last user relationship update time is exposed when listing friends. ### Changed - Replace metrics implementation. diff --git a/go.mod b/go.mod index b0d1e696b..8a3fe7482 100644 --- a/go.mod +++ b/go.mod @@ -29,7 +29,7 @@ require ( github.com/gorilla/mux v1.7.4 github.com/gorilla/websocket v1.4.2 github.com/grpc-ecosystem/grpc-gateway v1.13.0 - github.com/heroiclabs/nakama-common v1.5.0 + github.com/heroiclabs/nakama-common v1.5.1 github.com/jackc/fake v0.0.0-20150926172116-812a484cc733 // indirect github.com/jackc/pgx v3.5.0+incompatible github.com/jmhodges/levigo v1.0.0 // indirect diff --git a/go.sum b/go.sum index 7c25ed517..c8ce97ef5 100644 --- a/go.sum +++ b/go.sum @@ -100,8 +100,8 @@ github.com/gorilla/websocket v1.4.2/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grpc-ecosystem/grpc-gateway v1.13.0 h1:sBDQoHXrOlfPobnKw69FIKa1wg9qsLLvvQ/Y19WtFgI= github.com/grpc-ecosystem/grpc-gateway v1.13.0/go.mod h1:8XEsbTttt/W+VvjtQhLACqCisSPWTxCZ7sBRjU6iH9c= github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/heroiclabs/nakama-common v1.5.0 h1:AdTdt/sYvbi5vf3Q0y2YJQhCxAW1mZpCQPbjr26OUIg= -github.com/heroiclabs/nakama-common v1.5.0/go.mod h1:nZAXHdeo4SyPlCyf7pU9rCVizxEhBF74gt7teDe/EaQ= +github.com/heroiclabs/nakama-common v1.5.1 h1:ViCm9AvYYdQOCSKEa34SuSQ80JyZOHl6ODawESWf2wk= +github.com/heroiclabs/nakama-common v1.5.1/go.mod h1:nZAXHdeo4SyPlCyf7pU9rCVizxEhBF74gt7teDe/EaQ= github.com/hpcloud/tail v1.0.0 h1:nfCOvKYfkgYP8hkirhJocXT2+zOD8yUNjXaWfTlyFKI= github.com/hpcloud/tail v1.0.0/go.mod h1:ab1qPbhIpdTxEkNHXyeSf5vhxWSCs/tWer42PpOxQnU= github.com/inconshreveable/mousetrap v1.0.0/go.mod h1:PxqpIevigyE2G7u3NXJIT2ANytuPF1OarO4DADm73n8= diff --git a/server/core_friend.go b/server/core_friend.go index 281177243..9cc2df6b5 100644 --- a/server/core_friend.go +++ b/server/core_friend.go @@ -110,7 +110,7 @@ func ListFriends(ctx context.Context, logger *zap.Logger, db *sql.DB, tracker Tr query := ` SELECT id, username, display_name, avatar_url, lang_tag, location, timezone, metadata, - create_time, users.update_time, state, position + create_time, users.update_time, user_edge.update_time, state, position FROM users, user_edge WHERE id = destination_id AND source_id = $1` params = append(params, userID) if state != nil { @@ -153,10 +153,11 @@ FROM users, user_edge WHERE id = destination_id AND source_id = $1` var metadata []byte var createTime pgtype.Timestamptz var updateTime pgtype.Timestamptz + var edgeUpdateTime pgtype.Timestamptz var state sql.NullInt64 var position sql.NullInt64 - if err = rows.Scan(&id, &username, &displayName, &avatarURL, &lang, &location, &timezone, &metadata, &createTime, &updateTime, &state, &position); err != nil { + if err = rows.Scan(&id, &username, &displayName, &avatarURL, &lang, &location, &timezone, &metadata, &createTime, &updateTime, &edgeUpdateTime, &state, &position); err != nil { logger.Error("Error retrieving friends.", zap.Error(err)) return nil, err } @@ -196,6 +197,7 @@ FROM users, user_edge WHERE id = destination_id AND source_id = $1` State: &wrappers.Int32Value{ Value: int32(state.Int64), }, + UpdateTime: ×tamp.Timestamp{Seconds: edgeUpdateTime.Time.Unix()}, }) } if err = rows.Err(); err != nil { diff --git a/vendor/github.com/blevesearch/bleve/geo/geo.go b/vendor/github.com/blevesearch/bleve/geo/geo.go index b18ace433..077e73bf0 100644 --- a/vendor/github.com/blevesearch/bleve/geo/geo.go +++ b/vendor/github.com/blevesearch/bleve/geo/geo.go @@ -33,7 +33,7 @@ var minLonRad = minLon * degreesToRadian var minLatRad = minLat * degreesToRadian var maxLonRad = maxLon * degreesToRadian var maxLatRad = maxLat * degreesToRadian -var geoTolerance = 1e-6 +var geoTolerance = 1E-6 var lonScale = float64((uint64(0x1)<