From c13eb87ae73ac1ba78e22fd3a6fd547038cb23cb Mon Sep 17 00:00:00 2001 From: kim <89579420+NyaaaWhatsUpDoc@users.noreply.github.com> Date: Thu, 1 Feb 2024 12:45:02 +0000 Subject: [PATCH] stop paged endpoints returning null for empty items (#2597) --- internal/processing/account/block.go | 10 +++++----- internal/processing/common/account.go.go | 3 --- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/internal/processing/account/block.go b/internal/processing/account/block.go index 58b0328a4..49f81557d 100644 --- a/internal/processing/account/block.go +++ b/internal/processing/account/block.go @@ -151,6 +151,11 @@ func (p *Processor) BlocksGet( return util.EmptyPageableResponse(), nil } + // Get the lowest and highest + // ID values, used for paging. + lo := blocks[count-1].ID + hi := blocks[0].ID + items := make([]interface{}, 0, count) for _, block := range blocks { @@ -165,11 +170,6 @@ func (p *Processor) BlocksGet( items = append(items, account) } - // Get the lowest and highest - // ID values, used for paging. - lo := blocks[count-1].ID - hi := blocks[0].ID - return paging.PackageResponse(paging.ResponseParams{ Items: items, Path: "/api/v1/blocks", diff --git a/internal/processing/common/account.go.go b/internal/processing/common/account.go.go index c4436e77e..f4bd06e76 100644 --- a/internal/processing/common/account.go.go +++ b/internal/processing/common/account.go.go @@ -201,9 +201,6 @@ func (p *Processor) GetVisibleAPIAccountsPaged( length int, ) []interface{} { accounts := p.getVisibleAPIAccounts(ctx, 3, requester, next, length) - if len(accounts) == 0 { - return nil - } items := make([]interface{}, len(accounts)) for i, account := range accounts { items[i] = account