You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by se...@apache.org on 2016/08/24 13:22:38 UTC

[whimsy] branch master updated: Try to detect invalid joining dates

This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch master
in repository https://git-dual.apache.org/repos/asf/whimsy.git

The following commit(s) were added to refs/heads/master by this push:
       new  5bd229c   Try to detect invalid joining dates
5bd229c is described below

commit 5bd229ca49a2261a2bc8f4ef1d611a24de809910
Author: Sebb <se...@apache.org>
AuthorDate: Wed Aug 24 14:21:57 2016 +0100

    Try to detect invalid joining dates
---
 www/roster/public_committee_info.rb | 62 +++++++++++++++++++++++++------------
 1 file changed, 42 insertions(+), 20 deletions(-)

diff --git a/www/roster/public_committee_info.rb b/www/roster/public_committee_info.rb
index 9315e7f..52e7780 100644
--- a/www/roster/public_committee_info.rb
+++ b/www/roster/public_committee_info.rb
@@ -60,24 +60,46 @@ info[:committees] = Hash[committees.map {|committee|
 
 public_json_output(info)
 
-# Check if there is an unexpected entry
+# Check if there is an unexpected entry date
 # we only do this if the file has changed to avoid excessive reports
-# Doh - this won't work unless we just scan the changes.
-#if changed? or true
-#  last_updated = info[:last_updated]
-#  info[:committees].each { |pmc, entry|
-#    entry[:roster].each { |name, value|
-#      jdate = value[:date]
-#      if jdate
-#        joined = Date.parse(jdate,'').to_time
-#        # Joining date must not be before the file was updated
-#        # N.B. this won't be true for new PMCs - TODO allow for this
-#        if joined < last_updated
-#          msg = "Unexpected joining date: PMC: #{pmc} Id: #{name} entry: #{value} (last_updated: #{last_updated})"
-#          Wunderbar.warn msg
-#          sendMail('Error detected processing committee-info.txt', msg)
-#        end
-#      end
-#    }
-#  }
-#end
+if changed? and @old_file
+  # Note: symbolize_names=false to avoid symbolising variable keys such as pmc and user names
+  # However the current JSON (info) uses symbols for fixed keys - beware!
+  previous = JSON.parse(@old_file, :symbolize_names=>false)
+  previous_updated = Time.parse(previous['last_updated'])
+  previous = previous['committees']
+  last_updated = info[:last_updated] # This is a Time instance
+  # the joining date should normally be the same as the date when the file was updated:
+  updated_day1 = last_updated.strftime("%Y-%m-%d") # day of update
+  # and the date must be after the last_updated date of the previous file
+  # however for those in an earlier timezone it could be a few hours earlier
+  updated_day2 = (previous_updated-3600*4).strftime("%Y-%m-%d") # day of previous update
+
+  info[:committees].each { |pmc, entry|
+    previouspmc = previous[pmc] # get the original details (if any)
+    if previouspmc # we have an existing entry
+      entry[:roster].each { |name, value|
+        if !previouspmc['roster'][name] # new name, check the date is OK
+          newdate = value[:date]
+          if newdate <= updated_day1 and newdate >= updated_day2 # in range
+            Wunderbar.info "New member for #{pmc}: #{name} #{value[:name]} #{newdate}"
+          elsif newdate > updated_day1
+            Wunderbar.warn "Future-dated member for #{pmc}: #{name} #{value[:name]} #{newdate}"
+          else
+            Wunderbar.warn "Past-dated member for #{pmc}: #{name} #{value[:name]} #{newdate}"
+          end
+        end
+      }
+    else
+      Wunderbar.info "New PMC detected: #{pmc}"
+      # Could check that the joining dates are all the same?
+    end
+  }
+
+  previous.each { |pmc, entry|
+    if !info[:committees][pmc]
+      Wunderbar.info "Deleted PMC detected: #{pmc}"
+    end
+  }
+  sendMail('subj','body', to='sebbaz@gmail.com')
+end

-- 
To stop receiving notification emails like this one, please contact
['"commits@whimsical.apache.org" <co...@whimsical.apache.org>'].