whimsical-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ru...@apache.org
Subject [whimsy] 03/03: log reporter updates to back channel
Date Fri, 16 Aug 2019 18:46:42 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

commit 989e3b88a0dbea58a9f386ca0a69b9a4a66f2bfb
Author: Sam Ruby <rubys@intertwingly.net>
AuthorDate: Fri Aug 16 14:46:25 2019 -0400

    log reporter updates to back channel
---
 www/board/agenda/models/reporter.rb          |  2 ++
 www/board/agenda/views/models/chat.js.rb     | 50 ++++++++++++++++++++++++++++
 www/board/agenda/views/models/reporter.js.rb |  1 +
 3 files changed, 53 insertions(+)

diff --git a/www/board/agenda/models/reporter.rb b/www/board/agenda/models/reporter.rb
index a6e6189..66e777b 100644
--- a/www/board/agenda/models/reporter.rb
+++ b/www/board/agenda/models/reporter.rb
@@ -68,8 +68,10 @@ class Reporter
     results = {
       agenda: agenda_file,
       drafts: drafts.map {|project, status|
+        committee = ASF::Committee.find(project)
         [status['attach'], {
           project: project, 
+          title: (committee ? committee.display_name : project),
           timestamp: status['draft_timestamp'],
           author: status['last_author'],
           text: status['last_draft']
diff --git a/www/board/agenda/views/models/chat.js.rb b/www/board/agenda/views/models/chat.js.rb
index 45aa450..001519f 100644
--- a/www/board/agenda/views/models/chat.js.rb
+++ b/www/board/agenda/views/models/chat.js.rb
@@ -132,6 +132,56 @@ class Chat
     end
   end
 
+  # identify what changed in the reporter drafts
+  def self.reporter_change(before, after)
+    return unless before and before.drafts and after and after.drafts
+
+    # build an index of the 'before' drafts
+    index = {}
+    for attach in before.drafts
+      item = before.drafts[attach]
+      index[item.project] = item
+    end
+
+    # categorize each item in the 'after' drafts
+    add = []
+    change = []
+    for attach in after.drafts
+      item = after.drafts[attach]
+      before = index[item.project]
+      console.log [before, item]
+      if not before
+        add << item
+      else
+        change << item if before.text != item.text
+        index.delete item.project
+      end
+    end
+
+    # build a set of messages
+    messages = []
+    unless add.empty?
+      messages << "Added: #{add.map {|item| item.title}.join(', ')}"
+    end
+
+    unless change.empty?
+      messages << "Updated: #{change.map {|item| item.title}.join(', ')}"
+    end
+
+    missing = Object.values(index)
+    unless missing.empty?
+      messages << "Deleted: #{missing.map {|item| item.title}.join(', ')}"
+    end
+
+    # output the messages
+    unless messages.empty?
+      messages.each do |message|
+        Chat.add type: 'agenda', user: 'reporter', text: message
+      end
+      Main.refresh()
+    end
+  end
+
   # add an entry to the chat log
   def self.add(entry)
     entry.timestamp ||= Date.new().getTime()
diff --git a/www/board/agenda/views/models/reporter.js.rb b/www/board/agenda/views/models/reporter.js.rb
index cdaf5b3..70e1650 100644
--- a/www/board/agenda/views/models/reporter.js.rb
+++ b/www/board/agenda/views/models/reporter.js.rb
@@ -12,6 +12,7 @@ class Reporter
       @@forgotten ||= {}
       if not agenda or agenda == Agenda.file
         JSONStorage.fetch 'reporter' do |forgotten|
+          Chat.reporter_change(@@forgotten, forgotten)
           @@forgotten = forgotten
         end
       end


Mime
View raw message