Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add runtime leaderboardListCursorFromRank function #135

Merged
merged 2 commits into from
Oct 20, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,12 @@ All notable changes to this project are documented below.
The format is based on [keep a changelog](http://keepachangelog.com) and this project uses [semantic versioning](http://semver.org).

## [Unreleased]
### Added
- Runtime functions to build a leaderboardList cursor to start listing from a given rank.

### Fixed
- Fix linter-found test issue.
- Fix storage index listing results sometimes being returned with incorrect order.
- Fix storage index listing results sometimes being returned with incorrect order.

### Changed
- Add create_time and update_time to returned storage engine writes acks.
Expand Down
14 changes: 13 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4173,7 +4173,7 @@ declare namespace nkruntime {
* @returns The leaderboards data.
* @throws {TypeError, GoError}
*/
leaderboardList(limit?: number, cursor?: string): LeaderboardList;
leaderboardList(limit?: number, cursor?: string): LeaderboardList;

/**
* List records of a leaderboard.
Expand All @@ -4188,6 +4188,18 @@ declare namespace nkruntime {
*/
leaderboardRecordsList(leaderboardID: string, leaderboardOwners?: string[], limit?: number, cursor?: string, overrideExpiry?: number): LeaderboardRecordList;

/**
* Build a cursor to be used with leaderboardRecordsList to fetch records starting at a given rank.
* Only available if rank cache is not disabled for the leaderboard.
*
* @param leaderboardID - Leaderboard id.
* @param rank - The rank to start listing leaderboard records from.
* @param overrideExpiry - Opt. Override the expiryTime of the leaderboard to list older records.
* @returns A leaderboardRecordsList cursor.
* @throws {TypeError, GoError}
*/
leaderboardListCursorFromRank(leaderboardId: string, rank: number, expiryTime?: number): string
Copy link
Member

Choose a reason for hiding this comment

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

Function name inconsistent with Go runtime.


/**
* Write a new leaderboard record.
*
Expand Down
1 change: 1 addition & 0 deletions runtime/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -1078,6 +1078,7 @@ type NakamaModule interface {
LeaderboardDelete(ctx context.Context, id string) error
LeaderboardList(limit int, cursor string) (*api.LeaderboardList, error)
LeaderboardRecordsList(ctx context.Context, id string, ownerIDs []string, limit int, cursor string, expiry int64) (records []*api.LeaderboardRecord, ownerRecords []*api.LeaderboardRecord, nextCursor string, prevCursor string, err error)
LeaderboardRecordsListCursorFromRank(id string, rank, overrideExpiry int64) (string, error)
LeaderboardRecordWrite(ctx context.Context, id, ownerID, username string, score, subscore int64, metadata map[string]interface{}, overrideOperator *int) (*api.LeaderboardRecord, error)
LeaderboardRecordDelete(ctx context.Context, id, ownerID string) error
LeaderboardsGetId(ctx context.Context, ids []string) ([]*api.Leaderboard, error)
Expand Down