Commit b6dc3ff
committed
issue2551328/issue2551264 unneeded next link and total_count incorrect
Fix: issue2551328 - REST results show next link if number of
results is a multiple of page size. (Found by members of
team 3 in the UMass-Boston CS682 Spring 2024 class.)
issue2551264 - REST X-Total-Count header and @total_size
count incorrect when paginated
These issues arose because we retrieved the exact number of rows
from the database as requested by the user using the @page_size
parameter. With this changeset, we retrieve up to 10 million + 1
rows from the database. If the total number of rows exceeds 10
million, we set the total_count indicators to -1 as an invalid
size. (The max number of requested rows (default 10 million +1)
can be modified by the admin through interfaces.py.)
By retrieving more data than necessary, we can calculate the
total count by adding @page_index*@page_size to the number of
rows returned by the query.
Furthermore, since we return more than @page_size rows, we can
determine the existence of a row at @page_size+1 and use that
information to determine if a next link should be
provided. Previously, a next link was returned if @page_size rows
were retrieved.
This change does not guarantee that the user will get @page_size
rows returned. Access policy filtering occurs after the rows are
returned, and discards rows inaccessible by the user.
Using the current @page_index/@page_size it would be difficult to
have the roundup code refetch data and make sure that a full
@page_size set of rows is returned. E.G. @page_size=100 and 5 of
them are dropped due to access restrictions. We then fetch 10
items and add items 1-4 and 6 (5 is inaccessible). There is no
way to calculate the new database offset at:
@page_index*@page_size + 6 from the URL. We would need to add an
@page_offset=6 or something.
This could work since the client isn't adding 1 to @page_index to
get the next page. Thanks to HATEOAS, the client just uses the
'next' url. But I am not going to cross that bridge without a
concrete use case.
This can also be handled client side by merging a short response
with the next response and re-paginating client side.
Also added extra index markers to the docs to highlight use of
interfaces.py.1 parent d21ee54 commit b6dc3ff
File tree
7 files changed
+313
-20
lines changed- doc
- roundup
- test
7 files changed
+313
-20
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
105 | 105 | | |
106 | 106 | | |
107 | 107 | | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
108 | 116 | | |
109 | 117 | | |
110 | 118 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
259 | 259 | | |
260 | 260 | | |
261 | 261 | | |
| 262 | + | |
| 263 | + | |
262 | 264 | | |
263 | 265 | | |
264 | 266 | | |
| |||
320 | 322 | | |
321 | 323 | | |
322 | 324 | | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
323 | 350 | | |
324 | 351 | | |
325 | 352 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2176 | 2176 | | |
2177 | 2177 | | |
2178 | 2178 | | |
| 2179 | + | |
| 2180 | + | |
2179 | 2181 | | |
2180 | 2182 | | |
2181 | 2183 | | |
| |||
2202 | 2204 | | |
2203 | 2205 | | |
2204 | 2206 | | |
| 2207 | + | |
2205 | 2208 | | |
2206 | 2209 | | |
2207 | 2210 | | |
| |||
2241 | 2244 | | |
2242 | 2245 | | |
2243 | 2246 | | |
| 2247 | + | |
| 2248 | + | |
2244 | 2249 | | |
2245 | 2250 | | |
2246 | 2251 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1556 | 1556 | | |
1557 | 1557 | | |
1558 | 1558 | | |
| 1559 | + | |
| 1560 | + | |
1559 | 1561 | | |
1560 | 1562 | | |
1561 | 1563 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
491 | 491 | | |
492 | 492 | | |
493 | 493 | | |
494 | | - | |
495 | | - | |
496 | | - | |
497 | | - | |
498 | | - | |
| 494 | + | |
| 495 | + | |
| 496 | + | |
| 497 | + | |
| 498 | + | |
| 499 | + | |
| 500 | + | |
| 501 | + | |
| 502 | + | |
| 503 | + | |
| 504 | + | |
| 505 | + | |
499 | 506 | | |
500 | 507 | | |
501 | 508 | | |
| |||
517 | 524 | | |
518 | 525 | | |
519 | 526 | | |
520 | | - | |
521 | | - | |
522 | | - | |
523 | | - | |
524 | | - | |
| 527 | + | |
| 528 | + | |
| 529 | + | |
| 530 | + | |
| 531 | + | |
| 532 | + | |
| 533 | + | |
| 534 | + | |
| 535 | + | |
| 536 | + | |
| 537 | + | |
525 | 538 | | |
526 | 539 | | |
527 | 540 | | |
| |||
591 | 604 | | |
592 | 605 | | |
593 | 606 | | |
594 | | - | |
| 607 | + | |
| 608 | + | |
| 609 | + | |
595 | 610 | | |
596 | 611 | | |
597 | 612 | | |
| |||
1055 | 1070 | | |
1056 | 1071 | | |
1057 | 1072 | | |
1058 | | - | |
| 1073 | + | |
1059 | 1074 | | |
1060 | 1075 | | |
1061 | 1076 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
440 | 440 | | |
441 | 441 | | |
442 | 442 | | |
| 443 | + | |
| 444 | + | |
| 445 | + | |
| 446 | + | |
443 | 447 | | |
444 | 448 | | |
445 | 449 | | |
| |||
795 | 799 | | |
796 | 800 | | |
797 | 801 | | |
798 | | - | |
| 802 | + | |
799 | 803 | | |
800 | 804 | | |
801 | 805 | | |
| |||
910 | 914 | | |
911 | 915 | | |
912 | 916 | | |
913 | | - | |
914 | | - | |
| 917 | + | |
| 918 | + | |
| 919 | + | |
| 920 | + | |
| 921 | + | |
| 922 | + | |
| 923 | + | |
| 924 | + | |
| 925 | + | |
| 926 | + | |
| 927 | + | |
915 | 928 | | |
916 | 929 | | |
917 | 930 | | |
918 | 931 | | |
| 932 | + | |
| 933 | + | |
| 934 | + | |
| 935 | + | |
| 936 | + | |
919 | 937 | | |
920 | 938 | | |
921 | 939 | | |
| |||
930 | 948 | | |
931 | 949 | | |
932 | 950 | | |
933 | | - | |
| 951 | + | |
934 | 952 | | |
935 | 953 | | |
936 | 954 | | |
| |||
942 | 960 | | |
943 | 961 | | |
944 | 962 | | |
| 963 | + | |
| 964 | + | |
| 965 | + | |
| 966 | + | |
| 967 | + | |
| 968 | + | |
| 969 | + | |
| 970 | + | |
| 971 | + | |
| 972 | + | |
| 973 | + | |
| 974 | + | |
| 975 | + | |
| 976 | + | |
| 977 | + | |
| 978 | + | |
945 | 979 | | |
946 | 980 | | |
947 | 981 | | |
948 | 982 | | |
949 | 983 | | |
950 | 984 | | |
951 | | - | |
952 | | - | |
| 985 | + | |
| 986 | + | |
953 | 987 | | |
954 | 988 | | |
955 | 989 | | |
| |||
964 | 998 | | |
965 | 999 | | |
966 | 1000 | | |
967 | | - | |
968 | | - | |
| 1001 | + | |
| 1002 | + | |
969 | 1003 | | |
970 | 1004 | | |
971 | 1005 | | |
| |||
0 commit comments