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: cache posted reports
Date Fri, 08 Jul 2016 17:00:20 GMT
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  1060bce   cache posted reports
1060bce is described below

commit 1060bcee695de98def91739722d54bec9f187fe2
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Fri Jul 8 13:00:07 2016 -0400

    cache posted reports
---
 www/board/agenda/routes.rb                         |  5 +++
 .../agenda/views/actions/posted-reports.json.rb    | 51 ++++++++++++++++++++++
 www/board/agenda/views/models/posted.js.rb         |  8 ++--
 3 files changed, 60 insertions(+), 4 deletions(-)

diff --git a/www/board/agenda/routes.rb b/www/board/agenda/routes.rb
index aa83043..a62db84 100755
--- a/www/board/agenda/routes.rb
+++ b/www/board/agenda/routes.rb
@@ -122,6 +122,11 @@ get %r{^/(\d\d\d\d-\d\d-\d\d)$} do |date|
   redirect to("/#{date}/")
 end
 
+# posted reports
+get '/json/posted-reports' do
+  _json :"actions/posted-reports"
+end
+
 # posted actions
 post '/json/:file' do
   _json :"actions/#{params[:file]}"
diff --git a/www/board/agenda/views/actions/posted-reports.json.rb b/www/board/agenda/views/actions/posted-reports.json.rb
new file mode 100755
index 0000000..bdd6025
--- /dev/null
+++ b/www/board/agenda/views/actions/posted-reports.json.rb
@@ -0,0 +1,51 @@
+#
+# List of reports posted to board@
+#
+
+require 'date'
+require 'mail'
+require 'whimsy/asf/agenda'
+
+# link to board private-arch
+THREAD = "https://lists.apache.org/thread.html/"
+
+# only look at this month's and last month's mailboxes, and within those
+# only look at emails that were received in the last month.
+current = Date.today.strftime('%Y%m')
+previous = (Date.parse(current + '01')-1).strftime('%Y%m')
+cuttoff = Date.parse(previous + Date.today.strftime('%d')).to_time
+
+# get a list of current board messages
+archive = Dir["/srv/mail/board/#{previous}/*", "/srv/mail/board/#{current}/*"]
+
+# select messages that have a subject line starting with [REPORT]
+reports = []
+archive.each do |email|
+  email.untaint
+  next if File.mtime(email) < cuttoff
+  next if email.end_with? '/index'
+  message = IO.read(email, mode: 'rb')
+  subject = message[/^Subject: .*/]
+  next unless subject and subject.upcase.include? "[REPORT]"
+  mail = Mail.new(message)
+  reports << mail if mail.subject.upcase.start_with? "[REPORT]"
+end
+
+# Get a list of missing board reports
+Dir.chdir ASF::SVN['private/foundation/board']
+agenda = Dir['board_agenda_*.txt'].sort.last.untaint
+parsed = ASF::Board::Agenda.parse(IO.read(agenda), true)
+missing = parsed.select {|item| item['missing']}.
+  map {|item| item['title'].downcase}
+
+# produce output
+_ reports do |mail|
+  _subject mail.subject
+  _link THREAD + URI.escape('<' + mail.message_id + '>')
+
+  subject = mail.subject.downcase
+  _missing missing.any? {|title| subject =~ /\b#{title}\b/}
+
+  item = parsed.find {|item| subject =~ /\b#{item['title'].downcase}\b/}
+  _title item['title'] if item
+end
diff --git a/www/board/agenda/views/models/posted.js.rb b/www/board/agenda/views/models/posted.js.rb
index 674eefb..17a40d8 100644
--- a/www/board/agenda/views/models/posted.js.rb
+++ b/www/board/agenda/views/models/posted.js.rb
@@ -8,10 +8,10 @@ class Posted
     results = []
 
     # fetch list of reports on first reference
-    if not @@fetched and defined? XMLHttpRequest
-      @@list = JSONStorage.get('posted') || []
-      retrieve 'https://whimsy.apache.org/board/posted-reports', :json do |list|
-        @@list = JSONStorage.put('posted', list) if list
+    if not @@fetched
+      @@list = []
+      JSONStorage.fetch 'posted-reports' do |list|
+        @@list = list
       end
 
       @@fetched = true

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

Mime
View raw message