ga4gh-beacon / beacon-v2

Unified repository for the GA4GH Beacon v2 API standard
Creative Commons Zero v1.0 Universal
27 stars 22 forks source link

Pagination to add total number of pages for a query #117

Closed costero-e closed 8 months ago

costero-e commented 8 months ago

Hello all, currently, pagination does not show a number for the total number of pages given in a query response (e.g. you are looking at the page 7 out of 734). In other words, a beacon does not show the maximum skip number a particular query can have. I find this relevant, as one could be looking for rendering page by page the documents until the end of the documents retrieved, and not having this number could lead to discouraging people trying to look for all the results found. Right now, pagination looks like this:

        "Pagination": {
            "description": "Pagination to apply or that has been applied on the results.",
            "properties": {
                "currentPage": {
                    "$ref": "#/definitions/PageToken",
                    "description": "Token of the returned page. To be used only in the response to allow the client to check if the returned page is the one requested."
                },
                "limit": {
                    "$ref": "#/definitions/Limit"
                },
                "nextPage": {
                    "$ref": "#/definitions/PageToken",
                    "description": "Token of the next page. Used to navigate forward. If empty, it is assumed that no more pages are available"
                },
                "previousPage": {
                    "$ref": "#/definitions/PageToken",
                    "description": "Token of the previous page. Used to navigate backwards. If empty, it is assumed that the current page is the first one."
                },
                "skip": {
                    "$ref": "#/definitions/Skip"
                }
            },
            "type": "object"
        },

I would suggest adding something like, a maximum skip number, which could be the result of dividing the numTotalResults by the limit parameter:

"MaxSkip": {
"description": "In the response, the maximum number of pages that can be skipped. The number should be the result of the division of numTotalResults by the Limit parameter (number of documents displayed in a page).",
"example": 780,
"type": "integer"
},

I would like to know what is your opinion on this, thank you.

jrambla commented 8 months ago

Given that the client could easily do this calculation if required, do you see any additional benefit in having that in the response?

costero-e commented 8 months ago

I thought it could help if clients don't know there is a limit but it's true it's some extra work for the beacon that can be left out of the equation.