You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@couchdb.apache.org by eiri <gi...@git.apache.org> on 2016/08/09 14:24:17 UTC

[GitHub] couchdb-fabric pull request #65: Fix reply filter for open_revs

GitHub user eiri opened a pull request:

    https://github.com/apache/couchdb-fabric/pull/65

    Fix reply filter for open_revs

    Current filter removing all `not_found`'s from the final reply in presence of any `{ok, Doc}` in it, which is not always the correct behaviour, since we can have missing doc for one of the passed revisions. In general, in absence of `latest` attribute, we are expecting one reply per revision which could be either #doc or not found.
    
    This fix's making sure that we are removing `not_found`'s only for the revisions that also have `{ok, Doc}` reply.
    
    COUCHDB-3097

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/cloudant/couchdb-fabric 71693-fix-filter-out-not-found

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/couchdb-fabric/pull/65.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #65
    
----
commit f4f64b84c7ac742ad1533021d8c5b5ccd0221917
Author: Eric Avdey <ei...@eiri.ca>
Date:   2016-08-09T14:01:51Z

    Fix reply filter for open_revs

----


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fabric issue #65: Fix reply filter for open_revs

Posted by eiri <gi...@git.apache.org>.
Github user eiri commented on the issue:

    https://github.com/apache/couchdb-fabric/pull/65
  
    @davisp I did both, does it look better now?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fabric issue #65: Fix reply filter for open_revs

Posted by davisp <gi...@git.apache.org>.
Github user davisp commented on the issue:

    https://github.com/apache/couchdb-fabric/pull/65
  
    +1 after adding a comment or tweaking that bit of logic to be a bit less subtle.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fabric issue #65: Fix reply filter for open_revs

Posted by davisp <gi...@git.apache.org>.
Github user davisp commented on the issue:

    https://github.com/apache/couchdb-fabric/pull/65
  
    100% better. I kept staring at the {not_found, missing} tuple in both clauses of the fold and my brain just couldn't process what was going on for awhile. This is much better.
    
    +1 and good find on that.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fabric pull request #65: Fix reply filter for open_revs

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/couchdb-fabric/pull/65


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

[GitHub] couchdb-fabric pull request #65: Fix reply filter for open_revs

Posted by davisp <gi...@git.apache.org>.
Github user davisp commented on a diff in the pull request:

    https://github.com/apache/couchdb-fabric/pull/65#discussion_r74094851
  
    --- Diff: src/fabric_doc_open_revs.erl ---
    @@ -233,10 +234,15 @@ dict_format_replies(Dict) ->
         lists:sort([Reply || {_, {Reply, _}} <- Dict]).
     
     filter_reply(Replies) ->
    -    case [{ok, Doc} || {ok, Doc} <- Replies] of
    -        [] -> Replies;
    -        Filtered -> Filtered
    -    end.
    +    DropKeys = lists:foldl(fun
    +        ({{{not_found, missing}, _}, _}, Acc) ->
    +            Acc;
    +        ({{_, {Pos, [Rev | _]}}, _}, Acc) ->
    +            [{{not_found, missing}, {Pos, Rev}} | Acc]
    +    end, [], Replies),
    --- End diff --
    
    The logic of this and the filter below is a bit gnarly. It took me a good couple minutes to realize what was going on. I'd either add a short comment saying that you're building a list of fake not_found replies so that the filter function is simpler or to change the DropKeys to accumulate {Pos, Rev} and then use a slightly more complex filter that has to unpack key for not_found entries.


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---