whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] branch master updated: tool to convert new format votes into old format
Date Thu, 02 Apr 2020 13:28:40 GMT
This is an automated email from the ASF dual-hosted git repository.

rubys 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 a1a8406  tool to convert new format votes into old format
a1a8406 is described below

commit a1a8406552fe8395d1ba7387d37629949c76dc65
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Thu Apr 2 09:27:51 2020 -0400

    tool to convert new format votes into old format
---
 tools/votes2ini.rb | 38 ++++++++++++++++++++++++++++++++++++++
 1 file changed, 38 insertions(+)

diff --git a/tools/votes2ini.rb b/tools/votes2ini.rb
new file mode 100755
index 0000000..010a20c
--- /dev/null
+++ b/tools/votes2ini.rb
@@ -0,0 +1,38 @@
+#!/usr/bin/env ruby
+#
+# Convert "new format" raw_board_votes.json into "old format"
+# board_nominations.ini and raw_board_votes.txt for use by the whatif tool.
+#
+
+require 'json'
+
+raw_file = Dir["/srv/svn/Meetings/*/raw_board_votes.json"].sort.last
+raw_votes = JSON.parse(IO.read(raw_file))
+txt_file = raw_file.sub('.json', '.txt')
+ini_file = File.dirname(raw_file) + '/board_nominations.ini'
+
+votes = ''
+raw_votes['votes'].sort_by {|key, data| data['timestamp']}.each do |key, data|
+  time = Time.at(data['timestamp']).gmtime.strftime("%Y/%m/%d %H:%M:%S")
+  vote = data['vote'].split(' ').map {|vote| vote[-1]}.join.downcase
+  votes += "[#{time}] #{key[0..31]} #{vote}\n"
+end
+
+if !File.exist?(txt_file) or votes != IO.read(txt_file)
+  IO.write(txt_file, votes)
+end
+
+letter = 'a'
+ini =  "[nominees]\n"
+raw_votes['issue']['candidates'].each do |candidate|
+  ini += "#{letter}: #{candidate['name']}\n"
+  letter.succ!
+end
+
+if !File.exist?(ini_file) or ini != IO.read(ini_file)
+  IO.write(ini_file, ini)
+end
+
+puts votes
+puts
+puts ini


Mime
View raw message