Unverified Commit 5666361a authored by Simon Esposito's avatar Simon Esposito Committed by GitHub
Browse files

Add leaderboard record list around owner cursors (#877)

Minor improvement to leaderbord cache creation
Update nakama-common dependencies
parent 2192e990
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -11,6 +11,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
- Improve runtime handling of non-persisted purchases and subscriptions.
- Improve validation of count multiple matchmaker parameter.
- Stricter validation of devconsole user email inputs.
- Added next and previous cursor to results of the Leaderboard/TournamentRecordsAroundOwner API and Leaderboard/TournamentRecordsHaystack runtime functions.

## [3.12.0] - 2022-05-22
### Added

data/modules/index.js

deleted100644 → 0
+0 −12
Original line number Diff line number Diff line
"use strict";
var TEST_RPC = function (ctx, logger, nk, payload) {
    try {
        throw new Error('test_error');
    }
    catch (e) {
        throw e;
    }
};
var InitModule = function (ctx, logger, nk, initializer) {
    initializer.registerRpc('TEST_RPC', TEST_RPC);
};
+1 −1
Original line number Diff line number Diff line
@@ -13,7 +13,7 @@ require (
	github.com/gorilla/mux v1.8.0
	github.com/gorilla/websocket v1.4.2
	github.com/grpc-ecosystem/grpc-gateway/v2 v2.7.0
	github.com/heroiclabs/nakama-common v1.23.1-0.20220529114835-7f3eb1c918ff
	github.com/heroiclabs/nakama-common v1.23.1-0.20220705161131-2c524612cd4a
	github.com/jackc/pgconn v1.10.0
	github.com/jackc/pgerrcode v0.0.0-20201024163028-a0d42d470451
	github.com/jackc/pgtype v1.8.1
+2 −0
Original line number Diff line number Diff line
@@ -292,6 +292,8 @@ github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2p
github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc=
github.com/heroiclabs/nakama-common v1.23.1-0.20220529114835-7f3eb1c918ff h1:ulAC9PUbx+9hSwDBg+nHLNFa5uOZv0/lO93eecMRz0Q=
github.com/heroiclabs/nakama-common v1.23.1-0.20220529114835-7f3eb1c918ff/go.mod h1:WF4YG46afwY3ibzsXnkt3zvhQ3tBY03IYeU7xSLr8HE=
github.com/heroiclabs/nakama-common v1.23.1-0.20220705161131-2c524612cd4a h1:W8Od/R4nkjX14vnDWRMkc/9BFKEbFqwWQtvFl8H4tkY=
github.com/heroiclabs/nakama-common v1.23.1-0.20220705161131-2c524612cd4a/go.mod h1:WF4YG46afwY3ibzsXnkt3zvhQ3tBY03IYeU7xSLr8HE=
github.com/huandu/xstrings v1.3.2/go.mod h1:y5/lhBue+AyNmUVz9RLU9xbLR0o4KIIExikq4ovT0aE=
github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc=
+3 −5
Original line number Diff line number Diff line
@@ -262,24 +262,22 @@ func (s *ApiServer) ListLeaderboardRecordsAroundOwner(ctx context.Context, in *a
		overrideExpiry = in.Expiry.Value
	}

	records, err := LeaderboardRecordsHaystack(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, in.GetLeaderboardId(), ownerID, limit, overrideExpiry)
	records, err := LeaderboardRecordsHaystack(ctx, s.logger, s.db, s.leaderboardCache, s.leaderboardRankCache, in.GetLeaderboardId(), in.Cursor, ownerID, limit, overrideExpiry)
	if err == ErrLeaderboardNotFound {
		return nil, status.Error(codes.NotFound, "Leaderboard not found.")
	} else if err != nil {
		return nil, status.Error(codes.Internal, "Error querying records from leaderboard.")
	}

	recordList := &api.LeaderboardRecordList{Records: records}

	// After hook.
	if fn := s.runtime.AfterListLeaderboardRecordsAroundOwner(); fn != nil {
		afterFn := func(clientIP, clientPort string) error {
			return fn(ctx, s.logger, ctx.Value(ctxUserIDKey{}).(uuid.UUID).String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxVarsKey{}).(map[string]string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, recordList, in)
			return fn(ctx, s.logger, ctx.Value(ctxUserIDKey{}).(uuid.UUID).String(), ctx.Value(ctxUsernameKey{}).(string), ctx.Value(ctxVarsKey{}).(map[string]string), ctx.Value(ctxExpiryKey{}).(int64), clientIP, clientPort, records, in)
		}

		// Execute the after function lambda wrapped in a trace for stats measurement.
		traceApiAfter(ctx, s.logger, s.metrics, ctx.Value(ctxFullMethodKey{}).(string), afterFn)
	}

	return recordList, nil
	return records, nil
}
Loading