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

sebb pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/whimsy.git


The following commit(s) were added to refs/heads/master by this push:
     new cec94a7  Add counts
cec94a7 is described below

commit cec94a76122444d05bb0f9aedbe6b9a554f14a4a
Author: Sebb <[email protected]>
AuthorDate: Fri Sep 10 17:18:35 2021 +0100

    Add counts
---
 www/roster/public_ldap_services.rb | 35 +++++++++++++++++++++++------------
 1 file changed, 23 insertions(+), 12 deletions(-)

diff --git a/www/roster/public_ldap_services.rb 
b/www/roster/public_ldap_services.rb
index b78864b..b043213 100644
--- a/www/roster/public_ldap_services.rb
+++ b/www/roster/public_ldap_services.rb
@@ -2,9 +2,15 @@
 #
 # {
 #   "lastTimestamp": "20160119171152Z", // most recent modifyTimestamp
+#   "service_count": 15,
+#   "roster_counts": {
+#     "asf-secretary": 4,
+#     ...
+#   },
 #   "services": {
 #     "svnadmins": {
 #       "modifyTimestamp": "20111204095436Z",
+#       "roster_count": 123,
 #       "roster": ["uid",
 #       ...
 #       ]
@@ -26,25 +32,30 @@ if groups.empty?
   exit 0
 end
 
+roster_counts = Hash.new(0)
 lastStamp = ''
-groups.keys.sort_by {|a| a.name}.each do |entry|
-    next if entry.name == 'apldap' # infra team would prefer this not be 
publicized
+groups.keys.sort_by(&:name).each do |entry|
+  next if entry.name == 'apldap' # infra team would prefer this not be 
publicized
 
-    m = []
-    entry.members.sort_by {|a| a.name}.each do |e|
-        m << e.name
-    end
-    lastStamp = entry.modifyTimestamp if entry.modifyTimestamp > lastStamp
-    entries[entry.name] = {
-        createTimestamp: entry.createTimestamp,
-        modifyTimestamp: entry.modifyTimestamp,
-        roster: m
-    }
+  m = []
+  entry.members.sort_by(&:name).each do |e|
+    m << e.name
+  end
+  lastStamp = entry.modifyTimestamp if entry.modifyTimestamp > lastStamp
+  entries[entry.name] = {
+    createTimestamp: entry.createTimestamp,
+    modifyTimestamp: entry.modifyTimestamp,
+    roster_count: m.size,
+    roster: m
+  }
+  roster_counts[entry.name] = m.size
 end
 
 info = {
   # Is there a use case for the last createTimestamp ?
   lastTimestamp: lastStamp,
+  service_count: entries.size,
+  roster_counts: roster_counts,
   services: entries,
 }
 

Reply via email to