Refactor api pagination

This commit is contained in:
Arnau B
2020-11-09 12:56:35 +01:00
parent a4886c99ef
commit d2e9196fba
20 changed files with 257 additions and 359 deletions

View File

@@ -5,7 +5,6 @@ import (
"github.com/gin-gonic/gin"
"github.com/hermeznetwork/hermez-node/apitypes"
"github.com/hermeznetwork/hermez-node/db"
"github.com/hermeznetwork/hermez-node/db/historydb"
)
@@ -49,7 +48,7 @@ func (a *API) getAccounts(c *gin.Context) {
}
// Fetch Accounts from historyDB
apiAccounts, pagination, err := a.h.GetAccountsAPI(tokenIDs, addr, bjj, fromItem, limit, order)
apiAccounts, pendingItems, err := a.h.GetAccountsAPI(tokenIDs, addr, bjj, fromItem, limit, order)
if err != nil {
retSQLErr(err, c)
return
@@ -72,11 +71,11 @@ func (a *API) getAccounts(c *gin.Context) {
// Build succesfull response
type accountResponse struct {
Accounts []historydb.AccountAPI `json:"accounts"`
Pagination *db.Pagination `json:"pagination"`
Accounts []historydb.AccountAPI `json:"accounts"`
PendingItems uint64 `json:"pendingItems"`
}
c.JSON(http.StatusOK, &accountResponse{
Accounts: apiAccounts,
Pagination: pagination,
Accounts: apiAccounts,
PendingItems: pendingItems,
})
}