Skip to content

Commit

Permalink
Add runtime leaderboardRecordsListCursorFromRank function (#135)
Browse files Browse the repository at this point in the history
  • Loading branch information
sesposito authored Oct 20, 2023
1 parent b178843 commit 855feeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
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}
*/
leaderboardRecordsListCursorFromRank(leaderboardId: string, rank: number, expiryTime?: number): string

/**
* 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

0 comments on commit 855feeb

Please sign in to comment.