nickva commented on code in PR #4703:
URL: https://github.com/apache/couchdb/pull/4703#discussion_r1310578052


##########
src/fabric/src/fabric_rpc.erl:
##########
@@ -299,6 +299,10 @@ update_docs(DbName, Docs0, Options) ->
     Docs2 = make_att_readers(Docs1),
     with_db(DbName, Options, {couch_db, update_docs, [Docs2, Options, Type]}).
 
+get_purged_infos(DbName) ->
+    FoldFun = fun({_Seq, _UUID, Id, Revs}, Acc) -> {ok, [{Id, Revs} | Acc]} 
end,
+    with_db(DbName, [], {couch_db, fold_purge_infos, [0, FoldFun, []]}).

Review Comment:
   Seeing that we're dropping the `UUID` of the purge requests here, I wonder 
if my advice to return an `{Id : [Rev, ...]}` result was wrong. The reason is 
that it could be possible that there are two purge requests for the same 
document ID: two requests for same DocId but with different UUIDs and different 
lists of Revs. For example:
   
   `{_Seq, "abc123...", "doc1", ["rev1", "rev2"]}` and `{_Seq, "456def...", 
"doc1", ["rev3", "rev4"]}`
   
   When we emit them by ID our couch_lists:uniq/1 call will hide one of the 
purges.
   
   I can see a few choices then:
     * We could emit the UUID. But the users didn't define them, they were 
picked by our internal logic. So maybe we don't want to emit or return them to 
the user.
     * Don't emit the UUID and return a list of purge infos so we could get 
multiple purge infos for the same doc id. This is close to your original 
implementation. 
     * Combine the revs lists (append) for each doc ID. So if we have `{"doc1", 
["rev1", "rev2"]}` and `{"doc1", ["rev3", "rev4"]}` we'd return `{..., "doc1": 
["rev1", "rev2", "rev3"], ...}`. This would let us keep the same result shape 
as the purge request body.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to