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


##########
src/couch_mrview/src/couch_mrview_debug.erl:
##########
@@ -432,6 +492,107 @@ convert_collator_versions_to_strings(State) ->
     ),
     maps:put(collator_versions, CollatorVersions, State).
 
+active_signatures(DbName) when is_list(DbName) ->
+    active_signatures(list_to_binary(DbName));
+active_signatures(DbName) when is_binary(DbName) ->
+    [binary_to_list(S) || S <- sigs(DbName)].
+
+index_files(DbName) when is_list(DbName) ->
+    index_files(list_to_binary(DbName));
+index_files(DbName) when is_binary(DbName) ->
+    case shard_names(DbName) of
+        [] ->
+            [];
+        [_ | _] = Dbs ->
+            AllIndices = lists:map(fun couch_mrview_util:get_index_files/1, 
Dbs),
+            AsList = lists:sort(
+                lists:foldl(
+                    fun(Indices, Acc) ->
+                        maps:values(Indices) ++ Acc
+                    end,
+                    [],
+                    AllIndices
+                )
+            ),
+            [format_view_path(F) || F <- AsList]
+    end.
+
+stale_index_files(DbName) when is_list(DbName) ->
+    stale_index_files(list_to_binary(DbName));
+stale_index_files(DbName) when is_binary(DbName) ->
+    case shard_names(DbName) of
+        [] ->
+            [];
+        [Db1 | _] = Dbs ->
+            Sigs = couch_mrview_util:get_signatures(Db1),
+            AllIndices = lists:map(fun couch_mrview_util:get_index_files/1, 
Dbs),
+            AsList = lists:sort(
+                lists:foldl(
+                    fun(Indices, Acc) ->
+                        Inactive = maps:without(maps:keys(Sigs), Indices),
+                        maps:values(Inactive) ++ Acc
+                    end,
+                    [],
+                    AllIndices
+                )
+            ),
+            [format_view_path(F) || F <- AsList]
+    end.
+
+purge_checkpoints(DbName) when is_list(DbName) ->
+    purge_checkpoints(list_to_binary(DbName));
+purge_checkpoints(DbName) when is_binary(DbName) ->
+    case shard_names(DbName) of
+        [] ->
+            [];
+        [_ | _] = Dbs ->
+            AllPurges = lists:map(fun 
couch_mrview_util:get_purge_checkpoints/1, Dbs),
+            AsList = lists:sort(
+                lists:foldl(
+                    fun(Purges, Acc) ->
+                        maps:values(Purges) ++ Acc
+                    end,
+                    [],
+                    AllPurges
+                )
+            ),
+            [binary_to_list(DocId) || DocId <- AsList]
+    end.
+
+stale_purge_checkpoints(DbName) when is_list(DbName) ->
+    stale_purge_checkpoints(list_to_binary(DbName));
+stale_purge_checkpoints(DbName) when is_binary(DbName) ->
+    case shard_names(DbName) of
+        [] ->
+            [];
+        [Db1 | _] = Dbs ->
+            Sigs = couch_mrview_util:get_signatures(Db1),
+            AllPurges = lists:map(fun 
couch_mrview_util:get_purge_checkpoints/1, Dbs),
+            AsList = lists:sort(
+                lists:foldl(
+                    fun(Purges, Acc) ->
+                        Inactive = maps:without(maps:keys(Sigs), Purges),
+                        maps:values(Inactive) ++ Acc
+                    end,
+                    [],
+                    AllPurges
+                )
+            ),
+            [binary_to_list(DocId) || DocId <- AsList]
+    end.

Review Comment:
   It did look a bit repetitive. Maybe it's worth having an internal 
stale_purge_checkpoint_int(...) which takes a `shard_names(DbName)` result and 
then when returning we post-process it to turn them into more user-friendly 
list of strings?



-- 
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: notifications-unsubscr...@couchdb.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to