inmanta / inmanta-core

Inmanta is an automation and orchestration tool
https://inmanta.com
Apache License 2.0
27 stars 7 forks source link

paging behind last page returns 0 objects "before" #7898

Open sanderr opened 2 months ago

sanderr commented 2 months ago

If the filtering results in 0 objects, the API returns {"data": [], "metadata": {"total": 1, "before": 0, "after": 0, "page_size": 20} even if there are matching resources before it. The opposite is probably true for pages before the first one. This results in issues like inmanta/web-console#5894. Fixing this would prevent the need to reset the paging when a filter is added, as is the proposed solution in the linked ticket.

I believe that the reason for this is that we typically use the result set to determine the first and last element on the current page, and then use those as boundary elements to count the before and after. But I think it should be simple enough to handle this case: iff the result set is empty, simply drop all paging filters for the before count (in case of ASC) or the after count (in case of DESC). i.e. if the current page is empty, all other resources are before / after it.

wouterdb commented 6 days ago

Hey team! Please add your planning poker estimate with Zenhub @arnaudsjs @hlloreda @Hugo-Inmanta @jptrindade