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 046102b5 Include next committee report date calculation
046102b5 is described below

commit 046102b5369e95fe829d381eef80ece92c5638b9
Author: Sebb <[email protected]>
AuthorDate: Sat Jul 5 23:04:42 2025 +0100

    Include next committee report date calculation
---
 lib/whimsy/asf/board.rb | 20 ++++++++++++++++++--
 1 file changed, 18 insertions(+), 2 deletions(-)

diff --git a/lib/whimsy/asf/board.rb b/lib/whimsy/asf/board.rb
index c5948015..04a0a9db 100644
--- a/lib/whimsy/asf/board.rb
+++ b/lib/whimsy/asf/board.rb
@@ -75,10 +75,26 @@ module ASF
       time
     end
 
-    # Next 3 meetings as hash, e.g. {July => date1, August => date2, September 
=> date3}
+    # Next 3 meetings as hash, e.g. {July => date1, August => date2, September 
=> date3, Next => date1}
     # We assume dates don't have to be calculated
     def self.nextQuarter
-      self.calendar.select {|t| t > Time.now.utc}.sort.first(3).map {|d| 
[d.strftime('%B'), d]}.to_h
+      qr = self.calendar.select {|t| t > Time.now.utc}.sort.first(3)
+      h = qr.map {|d| [d.strftime('%B'), d]}.to_h
+      h['Next'] = h.first[1] # Ruby hashes retain insertion order so this will 
be the next meeting
+      h
+    end
+
+    # Get the next report date for a PMC or other committee
+    # Params:
+    # quarterdates - hash from nextQuarter
+    # schedule - list of report months (e.g. ["February", "May", "August", 
"November"])
+    #            possibly preceeded by 'Next month: ...'
+    #            or 'Every month' 
+    # Returns: the next date
+    def self.nextReport(quarterdates, schedule)
+      scfirst = schedule.first
+      return quarterdates['Next'] if scfirst and ( 
scfirst.start_with?('Every') or scfirst.start_with?('Next') )
+      quarterdates[schedule.select {|s| nextQuarter[s]}.first]
     end
 
     # time of previous meeting

Reply via email to