Skip to content

Commit

Permalink
Correctly handle leaderboard records previous page cursor.
Browse files Browse the repository at this point in the history
  • Loading branch information
zyro committed Jan 25, 2019
1 parent 07e315d commit 68c02ba
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr
## [Unreleased]
### Fixed
- Correctly return group user results in Lua runtime listing operation.
- Correctly handle leaderboard records previous page cursor.

## [2.3.2] - 2019-01-17
### Fixed
Expand Down
10 changes: 9 additions & 1 deletion server/core_leaderboard.go
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,15 @@ func LeaderboardRecordsList(ctx context.Context, logger *zap.Logger, db *sql.DB,

if incomingCursor != nil && !incomingCursor.IsNext {
// If this was a previous page listing, flip the results to their normal order and swap the cursors.
nextCursor, nextCursor.IsNext, nextCursor.Rank, prevCursor, prevCursor.IsNext, prevCursor.Rank = prevCursor, prevCursor.IsNext, prevCursor.Rank, nextCursor, nextCursor.IsNext, nextCursor.Rank
if nextCursor != nil && prevCursor != nil {
nextCursor, nextCursor.IsNext, nextCursor.Rank, prevCursor, prevCursor.IsNext, prevCursor.Rank = prevCursor, prevCursor.IsNext, prevCursor.Rank, nextCursor, nextCursor.IsNext, nextCursor.Rank
} else if nextCursor != nil {
nextCursor, prevCursor = nil, nextCursor
prevCursor.IsNext = !prevCursor.IsNext
} else if prevCursor != nil {
nextCursor, prevCursor = prevCursor, nil
nextCursor.IsNext = !nextCursor.IsNext
}

for i, j := 0, len(records)-1; i < j; i, j = i+1, j-1 {
records[i], records[i].Rank, records[j], records[j].Rank = records[j], records[j].Rank, records[i], records[i].Rank
Expand Down

0 comments on commit 68c02ba

Please sign in to comment.