Skip to content

Wrap Nakama Leaderboard Functions for Personalization#143

Merged
Calm0 merged 25 commits into
mainfrom
leaderboard-management-ops
Apr 2, 2026
Merged

Wrap Nakama Leaderboard Functions for Personalization#143
Calm0 merged 25 commits into
mainfrom
leaderboard-management-ops

Conversation

@andresfelipemendez
Copy link
Copy Markdown
Contributor

No description provided.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LeaderboardsSystem interface 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.

Comment thread hiro-openapi.yml Outdated
Comment thread hiro-openapi.yml Outdated
Comment thread hiro-openapi.yml
Comment thread leaderboards.go Outdated
Comment thread 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)
Copy link
Copy Markdown
Member

@Calm0 Calm0 Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need both ownerID and userID?

Comment thread 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
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, userID and ownerID?

Comment thread 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)
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should take ownerIDs []string instead of a singular?
And maybe include the expiry as well so it covers the base Nakama functionality?

Comment thread hiro.proto
Comment on lines +399 to +424
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;
}
Copy link
Copy Markdown
Member

@Calm0 Calm0 Jan 20, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this include a region as well? or do we wanna only rely on the leaderboard id?

@andresfelipemendez andresfelipemendez force-pushed the leaderboard-management-ops branch 4 times, most recently from 5b7eeef to bb41755 Compare January 22, 2026 18:12
Comment thread leaderboards.go Outdated
@Calm0 Calm0 force-pushed the leaderboard-management-ops branch from bcc896b to e904b2d Compare February 25, 2026 11:45
@Calm0 Calm0 marked this pull request as draft February 25, 2026 11:45
@andresfelipemendez andresfelipemendez requested a review from a team February 25, 2026 12:29
@Calm0 Calm0 marked this pull request as ready for review March 3, 2026 16:53
@Calm0 Calm0 requested a review from Copilot March 3, 2026 16:53
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 5 changed files in this pull request and generated 4 comments.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread hiro-openapi.yml
Comment thread hiro-openapi.yml
Comment thread hiro-openapi.yml Outdated
Comment thread leaderboards.go
@Calm0 Calm0 force-pushed the leaderboard-management-ops branch from a205512 to 14e3aec Compare March 18, 2026 13:57
@Calm0 Calm0 force-pushed the leaderboard-management-ops branch from 846a2b3 to 0bee033 Compare April 2, 2026 15:17
@Calm0 Calm0 merged commit 77d4366 into main Apr 2, 2026
2 checks passed
@Calm0 Calm0 deleted the leaderboard-management-ops branch April 2, 2026 16:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants