Nuklai / nuklaivm-external-subscriber

MIT License
0 stars 0 forks source link

Endpoints with pagination don’t show counter for all items #12

Closed kpachhai closed 1 day ago

kpachhai commented 4 days ago

Endpoints with pagination don’t show counter for all items. With this info, we don’t know how many pages there are and we cannot paginate it. We need endpoints that return something like { counter: number, items: Array }

rafael-ab commented 4 days ago

We have the following use cases, from this mocked transactions table where can show up to 10 items per page image You can see that the paginator component below has some pages being represented by these dots.

We need the counter which contains number of all items in the transactions or blocks to navigate, and needed to automatize this action, for example:

Total transactions: 50 Limit: 10

In this case we will have a maximum offset of 5, because there are 50 transactions

offset = current page * limit

we will use counter to stop going through offset 6, 7, 8... where there is no records.

I think there are no changes in current offset and limit, only by adding counter will solve the issue

kpachhai commented 1 day ago

This is now updated on dev branch.

Sample output from now on:

 {
      "counter": 73,
      "items": [
        {
          "BlockHeight": 73,
          "BlockHash": "p5jkYp2TfK1nH7WzXmeDypNKmtnMoRpNLadYCDNYoRyrTvxZS",
          "ParentBlockHash": "6bMS7Gi5u4SRfHUrboQcjhvpEjMNaNpFU4s7EAzdqi5Vqcyrj",
          "StateRoot": "oz2McvCZbS8gfp9sFjZfAFKawZW8TdrGjwwETfPpcEro26mTh",
          "BlockSize": 307,
          "TxCount": 1,
          "TotalFee": 48500,
          "AvgTxSize": 307,
          "UniqueParticipants": 1,
          "Timestamp": "2024-12-02T11:47:09Z"
        },
        {
          "BlockHeight": 72,
          "BlockHash": "6bMS7Gi5u4SRfHUrboQcjhvpEjMNaNpFU4s7EAzdqi5Vqcyrj",
          "ParentBlockHash": "fStF9MQQwV7UKQK73Pp4reKBttRGuC1X4sQRoaiB1VTTT1eG3",
          "StateRoot": "2RuPbB1GejDpXG9pMxmmfUuP3XfLKrjmyNUXKbq8LSm6dALtL7",
          "BlockSize": 84,
          "TxCount": 0,
          "TotalFee": 0,
          "AvgTxSize": 0,
          "UniqueParticipants": 0,
          "Timestamp": "2024-12-02T11:48:12Z"
        }
      ]
    }