You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When a user changes the rows per page value, the limit parameter in the API request is set to this new value. However, this also changes the offset value. The offset value is multiplied by the index of the current page number -- which doesn't take into account the fact that the number of pages will be less in instances when the rows per page value is increased.
This is what leads to the bug. If the rows per page value is increased, in some situations this can cause the offset to be changed to a value beyond the actual number of jobs. This causes the API request to return an empty list. As there are no runs, the boolean check in the code resolves to false so renders the "No reductions to show for this instrument" message instead of the table.
How to replicate
Go to LOQ reductions.
Go to the last page (page 5) whilst "25 rows per page" is active.
Increase the rows per page to 100 (or whatever).
Table should disappear and be replaced by a message saying "No reductions to show for this instrument".
Explanation
Currently, LOQ has 123 jobs to show.
With the limit set to 25, on page 5 the API request will look like this and return a non-empty list:
api/instrument/LOQ/jobs?limit=25&offset=100
The calculation for the offset is: (5-1) * 25 = 100
But if we change the rows per page value to 100, the offset gets changed to a value well beyond 123 which results in an empty list:
api/instrument/LOQ/jobs?limit=100&offset=400
This is because the offset calculation thinks we're on page 5, when actually we should be on page 2.
So the calculation is doing: (5-1) * 100 = 400
Instead of (2-1) * 100 = 100
The text was updated successfully, but these errors were encountered:
Dagonite
changed the title
Increasing the rows per page widget when there aren't enough reductions left to show crashes the table
Increasing the rows per page widget causes the offset to increase too much and makes the table disappear
Feb 5, 2025
Dagonite
changed the title
Increasing the rows per page widget causes the offset to increase too much and makes the table disappear
Increasing the rows per page causes the offset to increase too much and makes the table disappear
Feb 5, 2025
Description
When a user changes the rows per page value, the
limit
parameter in the API request is set to this new value. However, this also changes theoffset
value. Theoffset
value is multiplied by the index of the current page number -- which doesn't take into account the fact that the number of pages will be less in instances when the rows per page value is increased.This is what leads to the bug. If the rows per page value is increased, in some situations this can cause the
offset
to be changed to a value beyond the actual number of jobs. This causes the API request to return an empty list. As there are no runs, the boolean check in the code resolves to false so renders the "No reductions to show for this instrument" message instead of the table.How to replicate
Explanation
Currently, LOQ has 123 jobs to show.
With the limit set to 25, on page 5 the API request will look like this and return a non-empty list:
The calculation for the offset is: (5-1) * 25 = 100
But if we change the rows per page value to 100, the offset gets changed to a value well beyond 123 which results in an empty list:
This is because the offset calculation thinks we're on page 5, when actually we should be on page 2.
So the calculation is doing: (5-1) * 100 = 400
Instead of (2-1) * 100 = 100
The text was updated successfully, but these errors were encountered: