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 6f05188  Centralise member file access routines
6f05188 is described below

commit 6f051880c01893edb630933ac94bc6238777ebbc
Author: Sebb <[email protected]>
AuthorDate: Fri Feb 11 00:46:26 2022 +0000

    Centralise member file access routines
---
 lib/whimsy/asf/member-files.rb | 12 +++++++++++-
 www/members/watch.cgi          |  5 +----
 2 files changed, 12 insertions(+), 5 deletions(-)

diff --git a/lib/whimsy/asf/member-files.rb b/lib/whimsy/asf/member-files.rb
index 286ec4b..e3e3fe6 100644
--- a/lib/whimsy/asf/member-files.rb
+++ b/lib/whimsy/asf/member-files.rb
@@ -5,6 +5,16 @@ module ASF
 
   class MemberFiles
 
+    # get the latest meeting directory or nomination file
+    def self.latest_meeting(name=nil)
+      if name.nil? # we want the parent directory
+        name = 'nominated-members.txt' # ensure the target directory has been 
set up
+        File.dirname([File.join(ASF::SVN['Meetings'], '[2-9][0-9]*', 
name)].max)
+      else
+        Dir[File.join(ASF::SVN['Meetings'], '[2-9][0-9]*', name)].max
+      end
+    end
+
     # Return a hash of nominees.
     # key: availid (name for board nominees)
     # value: hash of entries:
@@ -26,7 +36,7 @@ module ASF
       #    Nomination Statement:
 
       # Find most recent file:
-      nomfile = Dir[File.join(ASF::SVN['Meetings'], '*', name)].max
+      nomfile = latest_meeting(name)
 
       # It does not appear to be possible to have file open or read
       # automatically transcode strings, so we do it here.
diff --git a/www/members/watch.cgi b/www/members/watch.cgi
index 2dae2eb..1312329 100755
--- a/www/members/watch.cgi
+++ b/www/members/watch.cgi
@@ -10,8 +10,6 @@ require 'date'
 require 'wunderbar/bootstrap'
 require 'wunderbar/jquery/stupidtable'
 
-meetings = ASF::SVN['Meetings']
-
 _html do
   _head_ do
     _base href: File.dirname(ENV['SCRIPT_NAME'])
@@ -32,8 +30,7 @@ _html do
     ) do
       # start with the Watch List itself
       watch_list = ASF::Person.member_watch_list.keys
-      meeting =
-        File.dirname(Dir[File.join(meetings, '*', 
'nominated-members.txt')].max)
+      meeting = ASF::MemberFiles.latest_meeting
 
       nominations = ASF::MemberFiles.member_nominees.map {|k, _v| k}
 

Reply via email to