fathomnet / community-feedback

1 stars 0 forks source link

Pagination is broken in web UI #142

Closed kevinsbarnard closed 1 year ago

kevinsbarnard commented 1 year ago

@ermbutler @hohonuuli Due to the Micronaut 3 -> 4 serialization changes, the API no longer has totalPages in pageable endpoint responses. This is causing several frontend issues with pagination.

The community page: image

The submissions page: image

The account management (admin) interface: image

hohonuuli commented 1 year ago

Sanity check:

Request:

GET http://fathomnet.org:8080/users?size=10&page=0
Authorization: Bearer <token>

Response

HTTP/1.1 200 OK
date: Tue, 19 Sep 2023 21:26:19 GMT
Content-Type: application/json
content-encoding: gzip
content-length: 1832
connection: close

{
  "content": [
    // omitted for brevity
  ],
  "pageable": {
    "size": 10,
    "number": 0,
    "sort": {}
  },
  "totalSize": 500
}
hohonuuli commented 1 year ago

This is a micronaut serialization bug:

hohonuuli commented 1 year ago

From the API docs, totalPages is a default method on the Page interface. It looks like it's not getting picked up by micronaut's serialzation anymore. (It previously was when we used straight Jackson).

Also the work around proposed above is reported to no longer work.

It's probably best if we just roll our own totalPages method:

function totalPages(pageSize, totalSize) {

  if (totalSize <= pageSize) {
    return 1;
  }

  return Math.ceil(totalSize / pageSize);
}
hohonuuli commented 1 year ago

Fixed in release 1.3.3. I've deployed the fix to the fathomnet server.