fix(paging): return subset of rows if page start is in the middle
This change should cover this example scenario where select ended returning 4 rows. Row 3 Row 4 Row 5 <- page start Row 6 Here, only rows 5 and 6 should end up in the response. Before this change some rows could be duplicated across adjacent search pages.
This commit is contained in:
parent
e07aa2086b
commit
abf6f143e5
|
@ -422,10 +422,11 @@ accumulate_query_rows(
|
|||
NCursor when NCursor < PageStart ->
|
||||
{more, ResultAcc#{cursor => NCursor}};
|
||||
NCursor when NCursor < PageEnd ->
|
||||
SubRows = lists:nthtail(max(0, PageStart - Cursor - 1), Rows),
|
||||
{more, ResultAcc#{
|
||||
cursor => NCursor,
|
||||
count => Count + length(Rows),
|
||||
rows => [{Node, Rows} | RowsAcc]
|
||||
count => Count + length(SubRows),
|
||||
rows => [{Node, SubRows} | RowsAcc]
|
||||
}};
|
||||
NCursor when NCursor >= PageEnd ->
|
||||
SubRows = lists:sublist(Rows, Limit - Count),
|
||||
|
|
Loading…
Reference in New Issue