From 13304682c0973bcb18908e9f441c28de40c863ec Mon Sep 17 00:00:00 2001 From: Andrei Mihu Date: Mon, 25 May 2020 15:08:04 +0100 Subject: [PATCH] Sort wallet ledger listings by creation time from newest to oldest. --- CHANGELOG.md | 3 ++- server/core_wallet.go | 5 ++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 654f1c443..079c1e7a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,8 +23,9 @@ The format is based on [keep a changelog](http://keepachangelog.com) and this pr - Only perform user account updates if fields have changed. - Developer console status snapshot gauges more accurately reflect current server metrics. - Disconnect match participants when an authoritative match ends due to an error. +- Sort wallet ledger listings by creation time from newest to oldest. - Build with Go 1.14.3 release. -- Update to nakama-common 1.5.0. +- Update to nakama-common 1.5.1. ### Fixed - Ensure runtime environment values do not appear multiple times in the devconsole configuration view. diff --git a/server/core_wallet.go b/server/core_wallet.go index 952e6d7df..eb9cc69df 100644 --- a/server/core_wallet.go +++ b/server/core_wallet.go @@ -264,8 +264,11 @@ func ListWalletLedger(ctx context.Context, logger *zap.Logger, db *sql.DB, userI query := "SELECT id, changeset, metadata, create_time, update_time FROM wallet_ledger WHERE user_id = $1::UUID" if incomingCursor != nil { params = append(params, incomingCursor.CreateTime, incomingCursor.Id) - query += " AND (user_id, create_time, id) > ($1::UUID, $2, $3::UUID)" + query += " AND (user_id, create_time, id) < ($1::UUID, $2, $3::UUID)" + } else { + query += " AND (user_id, create_time, id) < ($1::UUID, now(), '00000000-0000-0000-0000-000000000000'::UUID)" } + query += " ORDER BY create_time DESC" if limit != nil { params = append(params, *limit+1) query += " LIMIT $" + strconv.Itoa(len(params)) -- GitLab