Skip to content

Commit

Permalink
simplified using built in couch utilities
Browse files Browse the repository at this point in the history
  • Loading branch information
zachlankton committed Aug 30, 2022
1 parent 0b4b538 commit 0f9df2e
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions src/fabric/src/fabric_view_all_docs.erl
Original file line number Diff line number Diff line change
Expand Up @@ -286,22 +286,15 @@ all_docs_concurrency() ->
10
end.

get_query_list(undefined) ->
[];
get_query_list(List) when is_list(List) ->
List.
validate_if_partition(Row, Acc) ->
QueryList = get_query_list(Acc#vacc.req#httpd.qs),
case couch_util:get_value("partition", QueryList) of
case chttpd:qs_value(Acc#vacc.req, "partition") of
undefined -> Row;
Id -> is_doc_in_partition(Row, Id)
Partition -> is_doc_in_partition(Row, list_to_binary(Partition))
end.
is_doc_in_partition(Row, Id) ->
BinRowKey = Row#view_row.key,
IsDocInPartition = binary:match(BinRowKey, list_to_binary(Id)) /= nomatch,
case IsDocInPartition of
is_doc_in_partition(Row, Partition) ->
case couch_partition:is_member(Row#view_row.key, Partition) of
true -> Row;
false -> #view_row{key = BinRowKey}
false -> #view_row{key = Row#view_row.key}
end.

doc_receive_loop(Keys, Pids, SpawnFun, MaxJobs, Callback, AccIn) ->
Expand Down

0 comments on commit 0f9df2e

Please sign in to comment.