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
The following commit(s) were added to refs/heads/master by this push:
new b9eee6c Add cohort function
b9eee6c is described below
commit b9eee6c8f9cd1d9e6022eb0dfcfcadb54eedcc55
Author: Shane Curcuru <[email protected]>
AuthorDate: Sat Feb 15 21:11:33 2020 -0500
Add cohort function
---
www/members/meeting-util.rb | 21 ++++++++++++++++++++-
1 file changed, 20 insertions(+), 1 deletion(-)
diff --git a/www/members/meeting-util.rb b/www/members/meeting-util.rb
index d03844f..998ddad 100644
--- a/www/members/meeting-util.rb
+++ b/www/members/meeting-util.rb
@@ -78,4 +78,23 @@ class MeetingUtil
return JSON.parse(IO.read(File.join(mtg_root, 'attendance.json')))
end
-end
\ No newline at end of file
+ # Get a member's cohort (first meeting eligible to attend; typically year
after they were elected)
+ # @param mtg_root local copy of RECORDS
+ # @param att_cache hash from attendance.json (see also attend-matrix.py
elsewhere); Side effect is updated
+ # @param name of a Member (see also name mapping for various corrections)
+ def self.get_cohort(mtg_root, att_cache, name)
+ if att_cache.nil? or att_cache.empty?
+ att_cache = JSON.parse(IO.read(File.join(mtg_root, 'attendance.json')))
+ att_cache['cohorts'] = {}
+ # Precompute all cohorts, and leave cached
+ att_cache['members'].each do |date, names|
+ names.each do |nam|
+ att_cache['cohorts'][nam] = date
+ end
+ end
+ end
+ # TODO map any well-known mis-formatted names
+ return att_cache['cohorts'][name]
+ end
+
+end