You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whimsical.apache.org by ru...@apache.org on 2016/04/07 15:30:21 UTC

[whimsy] branch master updated: rough in server side of historical comments

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

rubys 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  1870cdb   rough in server side of historical comments
1870cdb is described below

commit 1870cdb4c265f7824ab8ef387c4f9d3563517af8
Author: Sam Ruby <ru...@intertwingly.net>
AuthorDate: Thu Apr 7 09:30:04 2016 -0400

    rough in server side of historical comments
---
 www/board/agenda/main.rb            |  1 +
 www/board/agenda/models/comments.rb | 42 +++++++++++++++++++++++++++++++++++++
 www/board/agenda/routes.rb          |  5 +++++
 3 files changed, 48 insertions(+)

diff --git a/www/board/agenda/main.rb b/www/board/agenda/main.rb
index baadbc7..c61e5c6 100755
--- a/www/board/agenda/main.rb
+++ b/www/board/agenda/main.rb
@@ -38,6 +38,7 @@ require_relative './models/pending'
 require_relative './models/events'
 require_relative './models/agenda'
 require_relative './models/minutes'
+require_relative './models/comments'
 require_relative './helpers/string'
 
 # if AGENDA_WORK doesn't exist yet, make it
diff --git a/www/board/agenda/models/comments.rb b/www/board/agenda/models/comments.rb
new file mode 100644
index 0000000..decd0b6
--- /dev/null
+++ b/www/board/agenda/models/comments.rb
@@ -0,0 +1,42 @@
+require 'whimsy/asf/agenda'
+require 'date'
+require 'json'
+
+class HistoricalComments
+  @@mtime = nil
+  @@comments = nil
+
+  def self.comments
+    # look for agendas in the last year + half a month
+    cutoff = (Date.today - 380).strftime('board_agenda_%Y_%m_%d')
+
+    # select and sort agendas for meetings past the cutoff
+    agendas = Dir["#{ASF::SVN['private/foundation/board']}/**/board_agenda_*"].
+      select {|file| File.basename(file) > cutoff}.
+      sort_by {|file| File.basename(file)}.
+      map {|file| file.untaint}
+
+    # return previous results unless an agenda has been updated
+    mtime = agendas.map {|file| File.mtime(file)}.max
+    return @@comments if mtime == @@mtime
+
+    # drop latest agenda
+    agendas.pop
+
+    # initialize comments to empty hash of hashes
+    comments = Hash.new {|hash, key| hash[key] = {}}
+
+    # gather up titles and comments
+    agendas.reverse.each do |agenda|
+      date = agenda[/\d+_\d+_\d+/]
+      ASF::Board::Agenda.parse(File.read(agenda), true).each do |report|
+        next if report['comments'].to_s.empty?
+        comments[report['title']][date] = report['comments']
+      end
+    end
+
+    # cache and return results
+    @@mtime = mtime
+    @@comments = comments
+  end
+end
diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index 4a00565..d046bcb 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -246,3 +246,8 @@ get '/text/draft/:file' do |file|
     end
   end
 end
+
+# historical comments
+get '/historical-comments' do
+  _json HistoricalComments.comments
+end

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