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-228 - ICLA lookup for notinavail
Date Mon, 04 May 2020 16:49:54 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 4903a47  WHIMSY-228 - ICLA lookup for notinavail
4903a47 is described below

commit 4903a476b436a3a5fce327ac10c9449eb9c04446
Author: Sebb <sebb@apache.org>
AuthorDate: Mon May 4 17:49:37 2020 +0100

    WHIMSY-228 - ICLA lookup for notinavail
    
    Allow combined search of committers and pending ICLAs
---
 www/roster/main.rb                     | 55 ++++++++++++++++++++++++++++++++++
 www/roster/views/committerSearch.js.rb | 54 ++++++++++++++++++++++++++-------
 www/roster/views/committers.html.rb    | 18 +++++++----
 www/roster/views/index.html.rb         | 21 +++++++++++--
 4 files changed, 130 insertions(+), 18 deletions(-)

diff --git a/www/roster/main.rb b/www/roster/main.rb
index 27b7e5f..2d7f2ae 100755
--- a/www/roster/main.rb
+++ b/www/roster/main.rb
@@ -109,6 +109,61 @@ get '/committer/index.json' do
   index
 end
 
+
+# Handle individual committer (or member) records
+get '/committer2/' do
+  @auth = Auth.info(env)
+  # Restrict who can see this
+  pass unless @auth[:member] or @auth[:chair]
+  @notinavail = true
+  _html :committers
+end
+
+index2 = nil
+index2_time = nil
+index2_etag = nil
+get '/committer2/index.json' do
+  @auth = Auth.info(env)
+  # Restrict who can see this
+  pass unless @auth[:member] or @auth[:chair]
+  # recompute index if the data is 5 minutes old or older
+  index2 = nil if not index2_time or Time.now-index2_time >= 300
+
+  if not index2
+    # bulk loading the mail information makes things go faster
+    mail = Hash[ASF::Mail.list.group_by(&:last).
+      map {|person, list| [person, list.map(&:first)]}]
+
+    ASF::Person.preload(['id','name','mail','githubUsername'])
+    # build a list of people, their public-names, and email addresses
+    tmp = ASF::Person.list.sort_by(&:id).map {|person|
+      result = {id: person.id, name: person.public_name, mail: mail[person], githubUsername:
person.attrs['githubUsername'] || []}
+      result[:member] = true if person.asf_member?
+      result
+    }
+
+    ASF::ICLA.each {|icla|
+      if icla.id == 'notinavail'
+        iclaFile = ASF::ICLAFiles.match_claRef(icla.claRef)
+        tmp << { name: icla.name, mail: icla.email, claRef: icla.claRef, iclaFile:
iclaFile}
+      end
+    }
+    index2 = tmp.to_json
+
+    # cache
+    index2_time = Time.now
+    index2_etag = etag = Digest::MD5.hexdigest(index2)
+  end
+
+  # send response
+  last_modified index2_time
+  etag index2_etag
+  content_type 'application/json', charset: 'UTF-8'
+  expires [index2_time+300, Time.now+60].max
+  index2
+end
+
+
 get '/committer/:name.json' do |name|
   data =  Committer.serialize(name, env)
   pass unless data
diff --git a/www/roster/views/committerSearch.js.rb b/www/roster/views/committerSearch.js.rb
index 8f0e58c..4fc09a9 100644
--- a/www/roster/views/committerSearch.js.rb
+++ b/www/roster/views/committerSearch.js.rb
@@ -7,8 +7,15 @@ class CommitterSearch < Vue
   end
 
   def mounted()
+    if @@notinavail
+      local_var = 'roster-committers-notinavail'
+      url = 'committer2/index.json'
+    else
+      local_var = 'roster-committers'
+      url = 'committer/index.json'
+    end
     # start with (possibly stale) data from local storage when available
-    ls_committers = localStorage.getItem('roster-committers')
+    ls_committers = localStorage.getItem(local_var)
     if ls_committers
       @committers = JSON.parse(ls_committers)
       @ready = true
@@ -17,12 +24,12 @@ class CommitterSearch < Vue
 
     # load fresh data from the server
     Polyfill.require(%w(Promise fetch)) do
-      fetch('committer/index.json', credentials: 'include').then {|response|
+      fetch(url, credentials: 'include').then {|response|
         response.json().then do |committers|
           @committers = committers
           @ready = true
           self.change(target: {value: @search}) unless @search.empty?
-          localStorage.setItem('roster-committers', @committers.inspect)
+          localStorage.setItem(local_var, @committers.inspect)
         end
       }.catch {|error|
         console.log error
@@ -40,10 +47,16 @@ class CommitterSearch < Vue
     @committers.each do |person|
       if 
         search.all? {|part|
-          person.id.include? part or
-          person.name.downcase().include? part or
-          person.mail.any? {|mail| mail.include? part} or
-          person.githubUsername.any? {|ghun| ghun.downcase().include? part}
+          if person.id
+            person.id.include? part or
+            person.name.downcase().include? part or
+            person.mail.include? part
+            person.mail.any? {|mail| mail.include? part} or
+            person.githubUsername.any? {|ghun| ghun.downcase().include? part}
+          else
+            person.name.downcase().include? part or
+            person.mail.include? part
+          end
         }
       then
         unless @@exclude and @@exclude.include? person.id
@@ -90,14 +103,22 @@ class CommitterSearch < Vue
                 _th 'public name'
                 _th 'email'
                 _th 'githubUsername'
+                if @@notinavail
+                  _th 'ICLA'
+                end
               end
             end
 
             _tbody do
               list.each do |person|
                 _tr do
-                  _td "\u2795", data_id: person.id, onClick: self.select
-                  _td {_a person.id, href: "committer/#{person.id}"}
+                  if person.id
+                    _td "\u2795", data_id: person.id, onClick: self.select
+                    _td {_a person.id, href: "committer/#{person.id}"}
+                  else
+                    _td "\u2795"
+                    _td 'notinavail'
+                  end
 
                   if person.member
                     _td {_b person.name}
@@ -105,9 +126,20 @@ class CommitterSearch < Vue
                     _td person.name
                   end
 
-                  _td person.mail.first
+                  if person.id
+                    _td person.mail.first
+                  else
+                    _td person.mail
+                  end
 
-                  _td person.githubUsername.join(', ')
+                  if person.githubUsername
+                    _td person.githubUsername.join(', ')
+                  else
+                    _td ''
+                  end
+                  if @@notinavail
+                    _td { _a person.claRef, href: "https://svn.apache.org/repos/private/documents/iclas/#{person.iclaFile}"
}
+                  end
                 end
               end
 
diff --git a/www/roster/views/committers.html.rb b/www/roster/views/committers.html.rb
index 75b4bbd..ddf49b9 100644
--- a/www/roster/views/committers.html.rb
+++ b/www/roster/views/committers.html.rb
@@ -1,21 +1,29 @@
 #
-# A single committer
+# Search Committer list
 #
 
 _html do
   _base href: '..'
   _link rel: 'stylesheet', href: "stylesheets/app.css?#{cssmtime}"
-  _whimsy_body(
-    title: 'ASF Committer Search',
-    breadcrumbs: {
+  if @notinavail
+    breadcrumbs = {
+      roster: '.',
+      committer2: 'committer2/'
+    }
+  else
+    breadcrumbs = {
       roster: '.',
       committer: 'committer/'
     }
+  end
+  _whimsy_body(
+    title: 'ASF Committer Search',
+    breadcrumbs: breadcrumbs
   ) do
     _div_.main!
     _script src: "app.js?#{appmtime}"
     _.render '#main' do
-      _CommitterSearch
+      _CommitterSearch notinavail: @notinavail
     end
   end
 end
diff --git a/www/roster/views/index.html.rb b/www/roster/views/index.html.rb
index f89243f..cb35a40 100644
--- a/www/roster/views/index.html.rb
+++ b/www/roster/views/index.html.rb
@@ -13,6 +13,7 @@ _html do
         roster: '.'
       }
     ) do
+      person = ASF::Person.find(env.user)
       _table.counts do
 
         ### committers
@@ -34,6 +35,23 @@ _html do
           end
         end
 
+        if person.asf_member? or ASF.pmc_chairs.include? person
+          _tr do
+            _td do
+              _a @committers.length, href: 'committer2/'
+            end
+  
+            _td do
+              _a 'Committers', href: 'committer2/'
+            end
+  
+            _td do
+              _ 'Search for committers by name, user id, or email address.'
+              _ ' Also includes pending ICLAs'
+            end
+          end
+        end
+
         ### members
 
         _tr do
@@ -110,11 +128,10 @@ _html do
 
       end
 
-      person = ASF::Person.find(env.user)
       if person.asf_member? or ASF.pmc_chairs.include? person
         _hr
         _p do
-          _a 'ICLA Search ', href: 'icla/'
+          _a 'Search pending ICLAs', href: 'icla/'
           _span.glyphicon.glyphicon_lock :aria_hidden, class: "text-primary", aria_label:
"ASF Members and Officers"
         end
         _p do


Mime
View raw message