plugins/mod_storage_internal.lua
changeset 9907 2c5546cc5c70
parent 9899 6bd65bff03b5
child 10001 7c4631d7b6fb
--- a/plugins/mod_storage_internal.lua	Sat Mar 23 08:52:57 2019 +0000
+++ b/plugins/mod_storage_internal.lua	Mon Feb 25 15:48:28 2019 +0100
@@ -196,6 +196,16 @@
 	return array(items):pluck("when"):map(datetime.date):unique();
 end
 
+function archive:summary(username, query)
+	local iter, err = self:find(username, query)
+	if not iter then return iter, err; end
+	local summary = {};
+	for _, _, _, with in iter do
+		summary[with] = (summary[with] or 0) + 1;
+	end
+	return summary;
+end
+
 function archive:delete(username, query)
 	local cache_key = jid_join(username, host, self.store);
 	if not query or next(query) == nil then