Wrap Nakama Leaderboard Functions for Personalization#143
Wrap Nakama Leaderboard Functions for Personalization#143andresfelipemendez wants to merge 14 commits intomainfrom
Conversation
There was a problem hiding this comment.
Pull request overview
This PR wraps Nakama's leaderboard functions to enable personalization hooks, adding new RPC endpoints for writing, deleting, and listing leaderboard records. These operations allow the system to intercept and customize leaderboard interactions before delegating to Nakama's native implementation.
Changes:
- Extended the
LeaderboardsSysteminterface with six new methods for CRUD operations on leaderboards and records - Added four new RPC endpoints (IDs 126-129) for leaderboard record operations in the protobuf definitions
- Updated the OpenAPI specification with corresponding REST endpoints and schema definitions
Reviewed changes
Copilot reviewed 3 out of 4 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| leaderboards.go | Extended interface with Create, Delete, WriteRecord, DeleteRecord, ListRecords, and ListRecordsAroundOwner methods |
| hiro.proto | Added RPC IDs 126-129, Operator enum, and message types for leaderboard record operations |
| hiro-openapi.yml | Added REST endpoints for write, delete, and list operations with corresponding request/response schemas |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
leaderboards.go
Outdated
| Delete(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, id string) error | ||
|
|
||
| // WriteScore writes a leaderboard score. | ||
| WriteScore(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, userID, leaderboardID, ownerID, username string, score, subscore int64, metadata map[string]any, operator Operator, conditionalMetadataUpdate bool) (*Leaderboard, error) |
There was a problem hiding this comment.
Why do we need both ownerID and userID?
leaderboards.go
Outdated
| WriteScore(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, userID, leaderboardID, ownerID, username string, score, subscore int64, metadata map[string]any, operator Operator, conditionalMetadataUpdate bool) (*Leaderboard, error) | ||
|
|
||
| // DeleteScore deletes a leaderboard score. | ||
| DeleteScore(ctx context.Context, logger runtime.Logger, db *sql.DB, nk runtime.NakamaModule, userID, leaderboardID, ownerID string) error |
leaderboards.go
Outdated
| Get(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID string) (*LeaderboardConfigList, error) | ||
|
|
||
| // GetScores returns a specified leaderboard with scores. | ||
| GetScores(ctx context.Context, logger runtime.Logger, nk runtime.NakamaModule, userID, leaderboardID, ownerID string, limit int, cursor string) (*Leaderboard, error) |
There was a problem hiding this comment.
This should take ownerIDs []string instead of a singular?
And maybe include the expiry as well so it covers the base Nakama functionality?
| message Leaderboard { | ||
| // Leaderboard ID. | ||
| string id = 1; | ||
| // Score ordering. If true, lower scores are better. | ||
| bool ascending = 2; | ||
| // Score submission operator. | ||
| string operator = 3; | ||
| // The leaderboard reset schedule. | ||
| string reset_schedule = 4; | ||
| // Whether the leaderboard is authoritative or not. | ||
| bool authoritative = 5; | ||
| // Additional metadata properties. | ||
| map<string, string> additional_properties = 6; | ||
| // Participants and their scores. | ||
| repeated LeaderboardScore scores = 7; | ||
| // Owner scores. | ||
| repeated LeaderboardScore owner_scores = 8; | ||
| // Next page cursor. | ||
| string next_cursor = 9; | ||
| // Previous page cursor. | ||
| string prev_cursor = 10; | ||
| // Total rank count. | ||
| int64 rank_count = 11; | ||
| // The UNIX timestamp for the current server time. | ||
| int64 current_time_sec = 12; | ||
| } |
There was a problem hiding this comment.
Shouldn't this include a region as well? or do we wanna only rely on the leaderboard id?
3711c29 to
77d06c6
Compare
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
5b7eeef to
bb41755
Compare
No description provided.