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 31c045f rough in a 'bot' to log changes to the agenda 31c045f is described below commit 31c045f87087c94225a61918c3eaae6b9af94f25 Author: Sam Ruby <ru...@intertwingly.net> AuthorDate: Tue Jun 12 13:11:39 2018 -0400 rough in a 'bot' to log changes to the agenda --- www/board/agenda/views/models/agenda.js.rb | 2 ++ www/board/agenda/views/models/chat.js.rb | 54 ++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/www/board/agenda/views/models/agenda.js.rb b/www/board/agenda/views/models/agenda.js.rb index a2209c1..8dfaa06 100644 --- a/www/board/agenda/views/models/agenda.js.rb +++ b/www/board/agenda/views/models/agenda.js.rb @@ -16,6 +16,7 @@ class Agenda # each instance to their next and previous items. def self.load(list, digest) return unless list + before = @@index @@digest = digest @@index = [] prev = nil @@ -55,6 +56,7 @@ class Agenda @@date = Date.new(@@index[0].timestamp).toISOString()[/(.*?)T/, 1] Main.refresh() + Chat.agenda_change(before, @@index) return @@index end diff --git a/www/board/agenda/views/models/chat.js.rb b/www/board/agenda/views/models/chat.js.rb index 43d6cd4..d964341 100644 --- a/www/board/agenda/views/models/chat.js.rb +++ b/www/board/agenda/views/models/chat.js.rb @@ -52,6 +52,60 @@ class Chat @@log end + # identify what changed in the agenda + def self.agenda_change(before, after) + return unless before and before.length > 0 + + # build an index of the 'before' agenda + index = {} + before.each do |item| + index[item.title] = item + end + + # categorize each item in the 'after' agenda + add = [] + change = [] + after.each do |item| + before = index[item.title] + if not before + add << item + elsif before.missing or not item.missing + if before.digest != item.digest + if before.missing + add << item + else + change << item + end + end + + index.delete item.title + 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: 'agenda', text: message + end + Main.refresh() + end + end + # add an entry to the chat log def self.add(entry) entry.timestamp ||= Date.new().getTime() -- To stop receiving notification emails like this one, please contact ru...@apache.org.