whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From s...@apache.org
Subject [whimsy] branch master updated: WHIMSY-261 - list counts on (P)PMC pages should not include archivers
Date Sat, 11 May 2019 11:06:45 GMT
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 53ab0a1  WHIMSY-261 - list counts on (P)PMC pages should not include archivers
53ab0a1 is described below

commit 53ab0a138ed88dbd9510a4313615e7d0769cda58
Author: Sebb <sebb@apache.org>
AuthorDate: Sat May 11 12:06:04 2019 +0100

    WHIMSY-261 - list counts on (P)PMC pages should not include archivers
---
 lib/whimsy/asf/mlist.rb            | 58 +++++++++++++++++++++++++++++---------
 www/roster/models/committee.rb     |  2 +-
 www/roster/models/nonpmc.rb        |  2 +-
 www/roster/models/ppmc.rb          |  2 +-
 www/roster/views/nonpmc/main.js.rb |  2 +-
 www/roster/views/pmc/main.js.rb    |  2 +-
 www/roster/views/ppmc/main.js.rb   |  2 +-
 7 files changed, 50 insertions(+), 20 deletions(-)

diff --git a/lib/whimsy/asf/mlist.rb b/lib/whimsy/asf/mlist.rb
index 14308fc..9f26661 100644
--- a/lib/whimsy/asf/mlist.rb
+++ b/lib/whimsy/asf/mlist.rb
@@ -145,17 +145,19 @@ module ASF
 
     # for a mail domain, extract related lists and their subscribers (default only the count)
     # also returns the time when the data was last checked
+    # N.B. by default includes archivers as subscribers
     # For top-level apache.org lists, the mail_domain is either:
     # - the full list name (e.g. press), or:
     # - the list prefix (e.g. legal)
     # If podling==true, then also check for old-style podling names
     # If list_subs==true, return subscriber emails else sub count
+    # If skip_archivers==true, exclude archivers
     # Matches:
     # {mail_domain}.apache.org/*
     # apache.org/{mail_domain}(-.*)? (e.g. press, legal)
     # incubator.apache.org/{mail_domain}-.* (if podling==true)
     # Returns: {list}@{dom}
-    def self.list_subscribers(mail_domain, podling=false, list_subs=false)
+    def self.list_subscribers(mail_domain, podling=false, list_subs=false, skip_archivers=false)
 
       return nil, nil unless File.exist? LIST_SUBS
 
@@ -179,11 +181,34 @@ module ASF
         next unless "#{mail_domain}.apache.org" == dom or
            (dom == 'apache.org' &&  list =~ /^#{mail_domain}(-|$)/) or
            (podling && dom == 'incubator.apache.org' && list =~ /^#{mail_domain}-/)
-        subscribers["#{list}@#{dom}"] = list_subs ? subs.sort : subs.size
+
+        if skip_archivers
+          subscribers["#{list}@#{dom}"] = list_subs ? subs.reject{|sub| is_archiver?(sub)}.sort
: subs.reject{|sub| is_archiver?(sub)}.size
+        else
+          subscribers["#{list}@#{dom}"] = list_subs ? subs.sort : subs.size
+        end
       end
       return subscribers.to_h, (File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS))
     end
 
+    # for a mail domain, extract related lists and their subscribers (default only the count)
+    # also returns the time when the data was last checked
+    # N.B. excludes archivers
+    # For top-level apache.org lists, the mail_domain is either:
+    # - the full list name (e.g. press), or:
+    # - the list prefix (e.g. legal)
+    # If podling==true, then also check for old-style podling names
+    # If list_subs==true, return subscriber emails else sub count
+    # Matches:
+    # {mail_domain}.apache.org/*
+    # apache.org/{mail_domain}(-.*)? (e.g. press, legal)
+    # incubator.apache.org/{mail_domain}-.* (if podling==true)
+    # Returns: {list}@{dom}
+    def self.list_subs(mail_domain, podling=false, list_subs=false)
+      self.list_subscribers(mail_domain,podling,list_subs,true)
+    end
+    
+    
     # returns the list time (defaulting to list-subs time if the marker is not present)
     def self.list_time
       File.mtime(LIST_TIME) rescue File.mtime(LIST_SUBS)
@@ -298,7 +323,8 @@ module ASF
         if cached
           begin
             cached.each do |d,l,m|
-              yield d, l, m
+              # don't allow cache to be altered
+              yield d.freeze, l.freeze, m.freeze
             end
             return
           rescue WeakRef::RefError
@@ -320,10 +346,10 @@ module ASF
           dom = match[1].downcase # just in case
           list = match[2].downcase # just in case
           # Keep original case of email addresses
-          # TODO: a bit slow for subs file, implement cache of parsed file?
           mails = stanza.split(/\n/).select{|x| x =~ /@/}
           cache << [dom, list, mails]
-          yield dom, list, mails
+          # don't allow cache to be altered
+          yield dom.freeze, list.freeze, mails.freeze
         else
           # don't allow mismatches as that means the RE is wrong
           line=stanza[0..(stanza.index("\n")|| -1)]
@@ -364,12 +390,16 @@ module ASF
   end
 end
 
-#if __FILE__ == $0
-#  domain = ARGV.shift||'whimsical'
-#  p  ASF::MLIST.list_subscribers(domain)
-#  p  ASF::MLIST.list_subscribers(domain,false,true)
-#  exit
-#  p  ASF::MLIST.list_moderators(domain, true)
-#  p  ASF::MLIST.private_subscribers(domain)
-#  p  ASF::MLIST.digests(['chrisd@apache.org'])
-#end
+if __FILE__ == $0
+  domain = ARGV.shift||'whimsical'
+  p  ASF::MLIST.list_subscribers(domain)
+  p  ASF::MLIST.list_subscribers(domain,false,false,true)
+  p  ASF::MLIST.list_subs(domain)
+  p  ASF::MLIST.list_subscribers(domain,false,true)
+  p  ASF::MLIST.list_subscribers(domain,false,true,true)
+  p  ASF::MLIST.list_subs(domain,false,true)
+  exit
+  p  ASF::MLIST.list_moderators(domain, true)
+  p  ASF::MLIST.private_subscribers(domain)
+  p  ASF::MLIST.digests(['chrisd@apache.org'])
+end
diff --git a/www/roster/models/committee.rb b/www/roster/models/committee.rb
index 6798e07..286af26 100644
--- a/www/roster/models/committee.rb
+++ b/www/roster/models/committee.rb
@@ -34,7 +34,7 @@ class Committee
     if pmc.roster.include? env.user or currentUser.asf_member?
       require 'whimsy/asf/mlist'
       moderators, modtime = ASF::MLIST.list_moderators(pmc.mail_list)
-      subscribers, subtime = ASF::MLIST.list_subscribers(pmc.mail_list) # counts only
+      subscribers, subtime = ASF::MLIST.list_subs(pmc.mail_list) # counts only, no archivers
       analysePrivateSubs = currentUser.asf_member?
       unless analysePrivateSubs # check for private moderator if not already allowed access
         # TODO match using canonical emails
diff --git a/www/roster/models/nonpmc.rb b/www/roster/models/nonpmc.rb
index 6b7776c..266ab0a 100644
--- a/www/roster/models/nonpmc.rb
+++ b/www/roster/models/nonpmc.rb
@@ -35,7 +35,7 @@ class NonPMC
     if cttee.roster.include? env.user or currentUser.asf_member?
       require 'whimsy/asf/mlist'
       moderators, modtime = ASF::MLIST.list_moderators(mail_list)
-      subscribers, subtime = ASF::MLIST.list_subscribers(mail_list) # counts only
+      subscribers, subtime = ASF::MLIST.list_subs(mail_list) # counts only, no archivers
       analysePrivateSubs = currentUser.asf_member?
       unless analysePrivateSubs # check for private moderator if not already allowed access
         user_mail = currentUser.all_mail || []
diff --git a/www/roster/models/ppmc.rb b/www/roster/models/ppmc.rb
index a833508..fc65304 100644
--- a/www/roster/models/ppmc.rb
+++ b/www/roster/models/ppmc.rb
@@ -29,7 +29,7 @@ class PPMC
     if currentUser.asf_member? or owners.include? currentUser
       require 'whimsy/asf/mlist'
       moderators, modtime = ASF::MLIST.list_moderators(ppmc.mail_list, true)
-      subscribers, subtime = ASF::MLIST.list_subscribers(ppmc.mail_list, true) # counts only
+      subscribers, subtime = ASF::MLIST.list_subs(ppmc.mail_list, true) # counts only, no
archivers
       analysePrivateSubs = currentUser.asf_member?
       unless analysePrivateSubs # check for private moderator if not already allowed access
         # TODO match using canonical emails
diff --git a/www/roster/views/nonpmc/main.js.rb b/www/roster/views/nonpmc/main.js.rb
index 6c708a6..3b88940 100644
--- a/www/roster/views/nonpmc/main.js.rb
+++ b/www/roster/views/nonpmc/main.js.rb
@@ -86,7 +86,7 @@ class NonPMC < Vue
     if @nonpmc.moderators
       _h2.mail! do
         _ 'Mailing list info'
-        _small ' (subscriber count includes archivers)'
+        _small ' (subscriber count excludes archivers)'
       end
       _table do
         _thead do
diff --git a/www/roster/views/pmc/main.js.rb b/www/roster/views/pmc/main.js.rb
index 2e88fbb..e1771c8 100644
--- a/www/roster/views/pmc/main.js.rb
+++ b/www/roster/views/pmc/main.js.rb
@@ -102,7 +102,7 @@ class PMC < Vue
     if @committee.moderators
       _h2.mail! do
         _ 'Mailing list info'
-        _small ' (subscriber count includes archivers)'
+        _small ' (subscriber count excludes archivers)'
       end
       _table do
         _thead do
diff --git a/www/roster/views/ppmc/main.js.rb b/www/roster/views/ppmc/main.js.rb
index 8663195..f6d3ce9 100644
--- a/www/roster/views/ppmc/main.js.rb
+++ b/www/roster/views/ppmc/main.js.rb
@@ -101,7 +101,7 @@ class PPMC < Vue
     if @ppmc.moderators
       _h2.mail! do
         _ 'Mailing list info'
-        _small ' (subscriber count includes archivers)'
+        _small ' (subscriber count excludes archivers)'
       end
       _table do
         _thead do


Mime
View raw message