Skip to content

Conversation

@andresfelipemendez
Copy link
Contributor

No description provided.

Copy link
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.

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
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?

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
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?

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
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 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
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 3 times, most recently from 3711c29 to 77d06c6 Compare January 20, 2026 18:02
andresfelipemendez and others added 12 commits January 22, 2026 13:11
# Conflicts:
#	hiro.pb.go
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>
@andresfelipemendez andresfelipemendez force-pushed the leaderboard-management-ops branch from 5b7eeef to bb41755 Compare January 22, 2026 18:12
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