Skip to content

Commit

Permalink
Fix check_for_item_not_found for elastic/riak
Browse files Browse the repository at this point in the history
  • Loading branch information
arcusfelis committed Aug 17, 2022
1 parent 22b77f0 commit f6ae3c3
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
4 changes: 2 additions & 2 deletions big_tests/tests/mam_SUITE.erl
Original file line number Diff line number Diff line change
Expand Up @@ -2506,11 +2506,11 @@ pagination_simple_before10(Config) ->

pagination_simple_before3(Config) ->
RSM = #rsm_in{max = 5, direction = before, id = message_id(3, Config), simple = true},
pagination_test(before10, RSM, simple_range(1, 2, true), Config).
pagination_test(before3, RSM, simple_range(1, 2, true), Config).

pagination_simple_before6(Config) ->
RSM = #rsm_in{max = 5, direction = before, id = message_id(6, Config), simple = true},
pagination_test(before10, RSM, simple_range(1, 5, true), Config).
pagination_test(before6, RSM, simple_range(1, 5, true), Config).

pagination_simple_before1_pagesize0(Config) ->
%% No messages forwarded, but is_complete is set
Expand Down
9 changes: 4 additions & 5 deletions src/mam/mod_mam_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -1156,18 +1156,17 @@ is_policy_violation(TotalCount, Offset, MaxResultLimit, LimitPassed) ->
LookupResult :: mod_mam:lookup_result(),
R :: {ok, mod_mam:lookup_result()} | {error, item_not_found}.
check_for_item_not_found(#rsm_in{direction = before, id = ID},
PageSize, {TotalCount, Offset, MessageRows}) ->
_PageSize, {TotalCount, Offset, MessageRows}) ->
case maybe_last(MessageRows) of
{ok, #{id := ID}} = _IntervalEndpoint ->
Page = lists:sublist(MessageRows, PageSize),
{ok, {TotalCount, Offset, Page}};
{ok, #{id := ID}} ->
{ok, {TotalCount, Offset, list_without_last(MessageRows)}};
undefined ->
{error, item_not_found}
end;
check_for_item_not_found(#rsm_in{direction = aft, id = ID},
_PageSize, {TotalCount, Offset, MessageRows0}) ->
case MessageRows0 of
[#{id := ID} = _IntervalEndpoint | MessageRows] ->
[#{id := ID} | MessageRows] ->
{ok, {TotalCount, Offset, MessageRows}};
_ ->
{error, item_not_found}
Expand Down

0 comments on commit f6ae3c3

Please sign in to comment.