This is an automated email from the ASF dual-hosted git repository.

vatamane pushed a commit to branch prototype/fdb-replicator
in repository https://gitbox.apache.org/repos/asf/couchdb.git

commit 7aca652ce38fd4f4ea697bb9d3b4a02a03ed42f5
Author: Nick Vatamaniuc <[email protected]>
AuthorDate: Mon Jul 20 16:54:05 2020 -0400

    [wip] stats may be a map
---
 src/couch_replicator/src/couch_replicator_stats.erl | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/src/couch_replicator/src/couch_replicator_stats.erl 
b/src/couch_replicator/src/couch_replicator_stats.erl
index 37848b3..d300092 100644
--- a/src/couch_replicator/src/couch_replicator_stats.erl
+++ b/src/couch_replicator/src/couch_replicator_stats.erl
@@ -32,10 +32,22 @@
 new() ->
     orddict:new().
 
+new(#{} = Map) ->
+    AtomKeysMap = maps:fold(fun
+        (K, V, Acc) when is_binary(K) ->
+            K1 = binary_to_existing_atom(K, utf8),
+            Acc#{K1 => V};
+        (K, V, Acc) when is_atom(K) ->
+            Acc#{K => V}
+    end, #{}, Map),
+    maps:to_list(AtomKeysMap);
 new(Initializers0) when is_list(Initializers0) ->
     Initializers1 = lists:filtermap(fun fmap/1, Initializers0),
     orddict:from_list(Initializers1).
 
+to_json(Stats) ->
+    maps:from_list(Stats).
+
 missing_checked(Stats) ->
     get(missing_checked, Stats).
 

Reply via email to