whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From curc...@apache.org
Subject [whimsy] 04/04: Display cohorts in by month view
Date Mon, 17 Feb 2020 02:24:56 GMT
This is an automated email from the ASF dual-hosted git repository.

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

commit a7072e6f76d878bb1e32b409a8805d89fb8ff98d
Author: Shane Curcuru <asf@shanecurcuru.org>
AuthorDate: Sun Feb 16 21:24:38 2020 -0500

    Display cohorts in by month view
---
 www/members/list-traffic.cgi | 56 +++++++++++++++++++++++++++++++++++++-------
 1 file changed, 47 insertions(+), 9 deletions(-)

diff --git a/www/members/list-traffic.cgi b/www/members/list-traffic.cgi
index a2dc486..d1ffc49 100755
--- a/www/members/list-traffic.cgi
+++ b/www/members/list-traffic.cgi
@@ -10,6 +10,7 @@ require 'whimsy/asf/agenda'
 require 'date'
 require 'mail'
 require '../../tools/mboxhdr2csv.rb'
+require_relative 'meeting-util'
 
 user = ASF::Person.new($USER)
 unless user.asf_member?
@@ -26,9 +27,34 @@ SRV_MAIL = "/srv/mail/#{LIST_ROOT}"
 
 WEEK_TOTAL = '@@total' # Use @@ so it can't match who name/emails
 WEEK_START = '@@start'
+COHORT_STYLES = { # TODO find better ways to colorize
+  'Zero to two years' => 'text-warning',
+  'Two to five years' => 'text-success',
+  'Five to ten years' => 'text-info',
+  'Ten or more years' => 'text-primary',
+  'Non-members' => 'text-muted'
+}
+
+# Define simple styles for various 'ages' of Members
+# 1-2 years, 3-5 years, 5-10 years, 10+ years 
+def style_cohorts(cohorts)
+  today = Date.today.year
+  cohorts['cohorts'].each do |id, date|
+    case date[0,4].to_i
+    when (today-1)..today
+      cohorts['cohorts'][id] = COHORT_STYLES['Zero to two years']
+    when (today-5)...(today-1)
+      cohorts['cohorts'][id] = COHORT_STYLES['Two to five years']
+    when (today-10)...(today-5)
+      cohorts['cohorts'][id] = COHORT_STYLES['Five to ten years']
+    else
+      cohorts['cohorts'][id] = COHORT_STYLES['Ten or more years']
+    end
+  end
+end
 
 # Display monthly statistics for all available data
-def display_monthly(months:, nondiscuss:)
+def display_monthly(months:, nondiscuss:, cohorts:)
   months.sort.reverse.each do |month|
     data = MailUtils.get_mails_month(mailroot: SRV_MAIL, yearmonth: month, nondiscuss: nondiscuss)
     next if data.empty?
@@ -53,8 +79,13 @@ def display_monthly(months:, nondiscuss:)
         _ul.list_group do
           _li.list_group_item.list_group_item_info "Long Tail - All Senders"
           _li.list_group_item do
-            data[MailUtils::MAILCOUNT].each do |id, num|
-              _! "#{id} (#{num}), "
+            data[MailUtils::MAILCOUNT].each do |name, num|
+              id = (name.match(/.+[(](\w+)/) || [])[1]
+              if cohorts['cohorts'].has_key?(id)
+                _span! "#{name} (#{num}), ", class: "#{cohorts['cohorts'][id]}"
+              else
+                _span! "#{name} (#{num}), ", class: "#{cohorts['cohorts'][COHORT_STYLES['Non-member']]}"
+              end
             end
           end
         end
@@ -129,24 +160,31 @@ _html do
       helpblock: -> {
         _p %{
           This script displays simple (and likely slightly lossy) analysis of traffic on
the #{LIST_ROOT}@ mailing list.
-          In particular, mapping From: email to a committer may not work (meaning individual
senders may have multiple spots),
-          and Subject lines displayed may be truncated (meaning threads may not fully be
tracked).  Work in progress.
+          In particular, mapping From: email to a committer may not work (meaning individual
senders may have multiple spots
+          or be miscategorized).  Work in progress.  Server only stores last year of mail.
         }
         _p do
           _ 'Senders of more than 10% of all emails in a month are highlighted. '
           _ 'Senders of more than 20%, 10%, or 5% of all emails in a week are highlighted
in the '
           _a 'By week view (supply ?week in URL).', href: '?week'
         end
-
+        _p do
+          _ 'For the All Senders column, Members are colorized by approximate years of membership
like so: '
+          _br
+          COHORT_STYLES.each do |name, style|
+            _span "#{name}, ", class: "#{style}"
+          end
+          _ ' note that due to email address variations, some entries may be incorrectly
marked.'
+        end
       }
     ) do
       months = Dir["#{SRV_MAIL}/*"].map {|path| File.basename(path).untaint}.grep(/^\d+$/)
-      _.error "HACK - server log one"
-
+      attendance = MeetingUtil.get_attendance(ASF::SVN['Meetings'])
+      style_cohorts(attendance)
       if ENV['QUERY_STRING'].include? 'week'
         display_weekly(months: months, nondiscuss: MailUtils::NONDISCUSSION_SUBJECTS["<#{LIST_ROOT}.apache.org>"])
       else
-        display_monthly(months: months, nondiscuss: MailUtils::NONDISCUSSION_SUBJECTS["<#{LIST_ROOT}.apache.org>"])
+        display_monthly(months: months, nondiscuss: MailUtils::NONDISCUSSION_SUBJECTS["<#{LIST_ROOT}.apache.org>"],
cohorts: attendance)
       end
     end
   end


Mime
View raw message