Created
July 7, 2010 23:42
-
-
Save fdmanana/467450 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
doc_infos_after_filter(Req, DocInfo, Db, Style, DDocName, FilterName) -> | |
DocInfos = case Style of | |
main_only -> | |
[DocInfo]; | |
all_docs -> | |
[DocInfo#doc_info{revs=[Rev]} || Rev <- DocInfo#doc_info.revs] | |
end, | |
{_, PosDocInfoDict, Docs1} = lists:foldl( | |
fun(DI, {P, Dict, Acc}) -> | |
case couch_db:open_doc(Db, DI, [deleted, conflicts]) of | |
{ok, Doc} -> | |
{P + 1, dict:store(P, DI, Dict), [Doc | Acc]}; | |
_ -> | |
{P, Dict, Acc} | |
end | |
end, | |
{1, dict:new(), []}, | |
DocInfos | |
), | |
Docs = lists:reverse(Docs1), | |
{ok, Passes} = couch_query_servers:filter_docs( | |
Req, Db, DDoc, FName, Docs | |
), | |
{_, Filtered} = lists:foldl( | |
fun(true, {P, Acc}) -> | |
{P + 1, [dict:fetch(P, PosDocInfoDict) | Acc]}; | |
(_, {P, Acc} -> | |
{P + 1, Acc} | |
end, | |
{1, []}, | |
Passes | |
), | |
lists:reverse(Filtered). |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment