From ea0640d51907a501130dbab5f4920bb20d8cd309 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 14 Aug 2022 17:32:11 -0400 Subject: [PATCH 01/45] WIP --- .../reports/schedule_reports_controller.rb | 197 +++++++++++------- 1 file changed, 124 insertions(+), 73 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index a3811d346..f5aa71d46 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -1,48 +1,55 @@ class Reports::ScheduleReportsController < ApplicationController around_action :set_timezone + # + # Get the sched diffs based on "publication dates" + # def schedule_diff authorize Person, policy_class: Reports::ScheduleReportPolicy - # TODO: base the from and to on the publish ids and this will be ok as a get pd_from = PublicationDate.find params[:from] if params[:from] from = pd_from.timestamp if pd_from from ||= PublicationDate.order('created_at desc').first&.timestamp - from ||= Time.now - 2.year # TODO: for testing + from ||= Time.now - 2.year pd_to = PublicationDate.find params[:to] if params[:to] to = pd_to.timestamp if pd_to live = false - # changes = ChangeService.published_changes(from: from, to: to) changes = if to ChangeService.published_changes(from: from, to: to) else live = true ChangeService.session_changes(from: from) end - to ||= Time.now - workbook = FastExcel.open(constant_memory: true) - date_time_style = workbook.number_format(EXCEL_NBR_FORMAT) - session_time_changed = workbook.add_worksheet("Session Time Changed") - session_room_changed = workbook.add_worksheet("Session Room Changed") - session_title_changed = workbook.add_worksheet("Session Title Changed") - session_description_changed = workbook.add_worksheet("Session Description Changed") - session_added = workbook.add_worksheet("Sessions Add") - session_removed = workbook.add_worksheet("Sessions Removed") + workbook = FastExcel.open(constant_memory: true) + init_sheets(workbook: workbook) - participants_fully_dropped = workbook.add_worksheet("Participants Dropped") - participants_add_drop = workbook.add_worksheet("Participants Add Drop") + # Rails.logger.debug "******** CHANGES: #{changes[:sessions]}" + state_change_sessions = check_sessions_changed(changes: changes[:sessions], live: live) + fully_dropped = check_assignments_changed( + changes: changes[:assignments], + state_change_sessions: state_change_sessions + ) - tab_headers(session_time_changed, session_room_changed, session_title_changed, session_description_changed, session_added, session_removed, participants_add_drop, participants_fully_dropped) + fully_dropped.uniq.each do |name| + @participants_fully_dropped.append_row(name) + end - # Rails.logger.debug "******** CHANGES: #{changes[:sessions]}" + send_data workbook.read_string, + filename: "ScheduleDiff-#{from.strftime('%m-%d-%Y_%H_%M')}_to_#{to.strftime('%m-%d-%Y_%H_%M')}.xlsx", + disposition: 'attachment' + end + # + # + # + def check_sessions_changed(changes:, live:) state_change_sessions = [] - changes[:sessions].values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| + changes.values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| # Rails.logger.debug "******** CHANGE: #{change}" next unless change[:object] @@ -50,69 +57,76 @@ def schedule_diff if change[:changes]['room_id'] && change[:changes]['start_time'] && ((!change[:changes]['room_id'][0] && change[:changes]['room_id'][1]) || (!change[:changes]['start_time'][0] && change[:changes]['start_time'][1])) - session_added_row(session_added, change, date_time_style) - live_add(session: change[:object], sheet: participants_add_drop) if live + session_added_row(@session_added, change) + live_add(session: change[:object], sheet: @participants_add_drop) if live next else if (change[:changes]['room_id'] && !change[:changes]['room_id'][1]) || (change[:changes]['start_time'] && !change[:changes]['start_time'][1])|| change[:event] == 'destroy' # Rails.logger.debug "******** removed because room or time" - session_removed_row(session_removed, change) - live_drop(session: change[:object], sheet: participants_add_drop) if live + session_removed_row(@session_removed, change) + live_drop(session: change[:object], sheet: @participants_add_drop) if live next else if change[:changes]['room_id'] - session_room_change_row(session_room_changed, change) + session_room_change_row(@session_room_changed, change) end if change[:changes]['start_time'] - session_time_change_row(session_time_changed, change, date_time_style) + session_time_change_row(@session_time_changed, change) end end end end if change[:object].start_time && change[:object].room_id - if change[:changes]['status'] - if (change[:changes]['status'][1] == 'draft' || change[:changes]['status'][1] == 'dropped') - # Rails.logger.debug "******** removed because draft" - session_removed_row(session_removed, change) - if live - live_drop(session: change[:object], sheet: participants_add_drop) - state_change_sessions << change[:object].id - end - next - elsif (change[:changes]['status'][0] == 'draft' || change[:changes]['status'][0] == 'dropped') - # Rails.logger.debug "******** added because state change" - session_added_row(session_added, change, date_time_style) - if live - live_add(session: change[:object], sheet: participants_add_drop) - state_change_sessions << change[:object].id - end - next + session_id = check_status_change(change: change, live: live) + + if session_id + state_change_sessions << session_id #change[:object].id + else + if change[:changes]['title'] + session_title_change_row(@session_title_changed, change) + end + if change[:changes]['description'] + session_description_change_row(@session_description_changed, change) end end - if change[:changes]['title'] - session_title_change_row(session_title_changed, change) - end - if change[:changes]['description'] - session_description_change_row(session_description_changed, change) - end + # if change[:changes]['status'] + # if (change[:changes]['status'][1] == 'draft' || change[:changes]['status'][1] == 'dropped') + # # Rails.logger.debug "******** removed because draft" + # session_removed_row(@session_removed, change) + # if live + # live_drop(session: change[:object], sheet: @participants_add_drop) + # state_change_sessions << change[:object].id + # end + # next + # elsif (change[:changes]['status'][0] == 'draft' || change[:changes]['status'][0] == 'dropped') + # # Rails.logger.debug "******** added because state change" + # session_added_row(@session_added, change) + # if live + # live_add(session: change[:object], sheet: @participants_add_drop) + # state_change_sessions << change[:object].id + # end + # next + # end + # end + end end - # Deal with the assignment changes + return state_change_sessions + end + + def check_assignments_changed(changes:, state_change_sessions:) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') roles = [moderator.id, participant.id] - # Rails.logger.debug "******** ROLES #{roles}" - # TODO: sort .... ??? how fully_dropped = [] - changes[:assignments].each do |id, change| - # next unless change[:object] + changes.each do |id, change| changed_assignment = change[:object] changed_assignment ||= SessionAssignment.find change[:session_assignment_id] - next if state_change_sessions.include? change[:object].session_id + next if state_change_sessions.include? changed_assignment.session_id session = changed_assignment.session if changed_assignment.session session ||= Session.find changed_assignment.session_id @@ -123,7 +137,7 @@ def schedule_diff if change[:changes]['session_assignment_role_type_id'] && change[:event] != 'destroy' if session.start_time && session.room_id if (roles.include?(change[:changes]['session_assignment_role_type_id'][1])) - participants_add_drop.append_row( + @participants_add_drop.append_row( [ session.title, '', @@ -131,7 +145,7 @@ def schedule_diff ] ) elsif (roles.include?(change[:changes]['session_assignment_role_type_id'][0])) - participants_add_drop.append_row( + @participants_add_drop.append_row( [ session.title, changed_assignment.person.published_name, @@ -145,7 +159,7 @@ def schedule_diff else # Rails.logger.debug "******** Assignment EVENT DROP ????" if change[:event] == 'destroy' - participants_add_drop.append_row( + @participants_add_drop.append_row( [ session.title, changed_assignment.person.published_name, @@ -158,25 +172,62 @@ def schedule_diff end end - fully_dropped.uniq.each do |name| - participants_fully_dropped.append_row(name) + return fully_dropped + end + + def check_status_change(change:, live: false) + return unless change[:changes]['status'] + return if ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) + + if ['draft', 'dropped'].include?(change[:changes]['status'][1]) + session_removed_row(@session_removed, change) + + if live + live_drop(session: change[:object], sheet: @participants_add_drop) + # state_change_sessions << + return change[:object].id + end + + return end - send_data workbook.read_string, - filename: "ScheduleDiff-#{from.strftime('%m-%d-%Y_%H_%M')}_to_#{to.strftime('%m-%d-%Y_%H_%M')}.xlsx", - disposition: 'attachment' + if ['draft', 'dropped'].include?(change[:changes]['status'][0]) + session_added_row(@session_added, change) + if live + live_add(session: change[:object], sheet: @participants_add_drop) + # state_change_sessions << + return change[:object].id + end + + return + end + end + + + def init_sheets(workbook:) + @session_time_changed = workbook.add_worksheet("Session Time Changed") + @session_room_changed = workbook.add_worksheet("Session Room Changed") + @session_title_changed = workbook.add_worksheet("Session Title Changed") + @session_description_changed = workbook.add_worksheet("Session Description Changed") + @session_added = workbook.add_worksheet("Sessions Add") + @session_removed = workbook.add_worksheet("Sessions Removed") + @participants_fully_dropped = workbook.add_worksheet("Participants Dropped") + @participants_add_drop = workbook.add_worksheet("Participants Add Drop") + + @date_time_style = workbook.number_format(EXCEL_NBR_FORMAT) + tab_headers end - def tab_headers(session_time_changed, session_room_changed, session_title_changed, session_description_changed, session_added, session_removed, participants_add_drop, participants_fully_dropped) - session_time_changed.append_row(['Session Title','Original Start Time', 'New Start Time']) - session_room_changed.append_row(['Session Title','Original Room', 'New Room']) - session_title_changed.append_row(['Original Session Title', 'New Session Title']) - session_description_changed.append_row(['Session Title','Original Description', 'New Description']) - session_added.append_row(['Session Title', 'Session Description', 'Format', 'Areas', 'Start Time', 'Room', 'Moderators', 'Participants']) - session_removed.append_row(['Session Title']) + def tab_headers + @session_time_changed.append_row(['Session Title','Original Start Time', 'New Start Time']) + @session_room_changed.append_row(['Session Title','Original Room', 'New Room']) + @session_title_changed.append_row(['Original Session Title', 'New Session Title']) + @session_description_changed.append_row(['Session Title','Original Description', 'New Description']) + @session_added.append_row(['Session Title', 'Session Description', 'Format', 'Areas', 'Start Time', 'Room', 'Moderators', 'Participants']) + @session_removed.append_row(['Session Title']) - participants_add_drop.append_row(['Session Title', 'Participant Dropped', 'Participant Added']) - participants_fully_dropped.append_row(['Participant Dropped']) + @participants_add_drop.append_row(['Session Title', 'Participant Dropped', 'Participant Added']) + @participants_fully_dropped.append_row(['Participant Dropped']) end def live_add(session:, sheet:) @@ -242,7 +293,7 @@ def session_removed_row(sheet, change) ) end - def session_time_change_row(sheet, change, date_time_style) + def session_time_change_row(sheet, change) orig_time = Time.parse(change[:changes]['start_time'][0]) if change[:changes]['start_time'][0] new_time = Time.parse(change[:changes]['start_time'][1]) if change[:changes]['start_time'][1] # Rails.logger.debug "********* #{change[:changes]['start_time'][1]} => #{new_time.class} #{new_time.strftime("%H")}" @@ -253,13 +304,13 @@ def session_time_change_row(sheet, change, date_time_style) new_time ? FastExcel.date_num(new_time, new_time.in_time_zone.utc_offset) : nil ], [ - nil, date_time_style, date_time_style + nil, @date_time_style, @date_time_style ] ) end # Generate a row for sessions added - def session_added_row(sheet, change, date_time_style) + def session_added_row(sheet, change) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') @@ -277,7 +328,7 @@ def session_added_row(sheet, change, date_time_style) change[:object].participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") ], [ - nil, nil, nil, nil, date_time_style, nil, nil, nil + nil, nil, nil, nil, @date_time_style, nil, nil, nil ] ) end From 7c3a65da91b2cc1ab366b4967464a814c49a833e Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 14 Aug 2022 17:53:53 -0400 Subject: [PATCH 02/45] WIP --- .../reports/schedule_reports_controller.rb | 34 +++++-------------- 1 file changed, 9 insertions(+), 25 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index f5aa71d46..9bdd4aac5 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -90,27 +90,6 @@ def check_sessions_changed(changes:, live:) session_description_change_row(@session_description_changed, change) end end - - # if change[:changes]['status'] - # if (change[:changes]['status'][1] == 'draft' || change[:changes]['status'][1] == 'dropped') - # # Rails.logger.debug "******** removed because draft" - # session_removed_row(@session_removed, change) - # if live - # live_drop(session: change[:object], sheet: @participants_add_drop) - # state_change_sessions << change[:object].id - # end - # next - # elsif (change[:changes]['status'][0] == 'draft' || change[:changes]['status'][0] == 'dropped') - # # Rails.logger.debug "******** added because state change" - # session_added_row(@session_added, change) - # if live - # live_add(session: change[:object], sheet: @participants_add_drop) - # state_change_sessions << change[:object].id - # end - # next - # end - # end - end end @@ -176,16 +155,21 @@ def check_assignments_changed(changes:, state_change_sessions:) end def check_status_change(change:, live: false) + # Rails.logger.debug "********* STATUS CHANGE" return unless change[:changes]['status'] return if ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) + # Rails.logger.debug "********* STATUS CHANGE ....." if ['draft', 'dropped'].include?(change[:changes]['status'][1]) - session_removed_row(@session_removed, change) - if live + return unless change[:object].published_session + + session_removed_row(@session_removed, change) live_drop(session: change[:object], sheet: @participants_add_drop) - # state_change_sessions << + return change[:object].id + else + session_removed_row(@session_removed, change) end return @@ -195,7 +179,7 @@ def check_status_change(change:, live: false) session_added_row(@session_added, change) if live live_add(session: change[:object], sheet: @participants_add_drop) - # state_change_sessions << + return change[:object].id end From 2a62ba904662d17c86c9eab2b9a548e3be5e8023 Mon Sep 17 00:00:00 2001 From: Henry Date: Sun, 14 Aug 2022 18:51:19 -0400 Subject: [PATCH 03/45] WIP --- .../reports/schedule_reports_controller.rb | 93 +++++++++++-------- 1 file changed, 55 insertions(+), 38 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 9bdd4aac5..64e9fcd86 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -29,7 +29,10 @@ def schedule_diff init_sheets(workbook: workbook) # Rails.logger.debug "******** CHANGES: #{changes[:sessions]}" - state_change_sessions = check_sessions_changed(changes: changes[:sessions], live: live) + state_change_sessions = check_sessions_changed( + changes: changes[:sessions], + live: live + ) fully_dropped = check_assignments_changed( changes: changes[:assignments], state_change_sessions: state_change_sessions @@ -50,30 +53,28 @@ def schedule_diff def check_sessions_changed(changes:, live:) state_change_sessions = [] changes.values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| - # Rails.logger.debug "******** CHANGE: #{change}" next unless change[:object] - if change[:changes]['room_id'] || change[:changes]['start_time'] - if change[:changes]['room_id'] && change[:changes]['start_time'] && - ((!change[:changes]['room_id'][0] && change[:changes]['room_id'][1]) || - (!change[:changes]['start_time'][0] && change[:changes]['start_time'][1])) + if (change[:changes]['room_id'] || change[:changes]['start_time']) && !change[:changes]['status'] + # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]['status']} " + if room_added?(change) || start_time_added?(change) session_added_row(@session_added, change) live_add(session: change[:object], sheet: @participants_add_drop) if live next - else - if (change[:changes]['room_id'] && !change[:changes]['room_id'][1]) || (change[:changes]['start_time'] && !change[:changes]['start_time'][1])|| change[:event] == 'destroy' - # Rails.logger.debug "******** removed because room or time" - session_removed_row(@session_removed, change) - live_drop(session: change[:object], sheet: @participants_add_drop) if live - next - else - if change[:changes]['room_id'] - session_room_change_row(@session_room_changed, change) - end - if change[:changes]['start_time'] - session_time_change_row(@session_time_changed, change) - end - end + end + + if room_removed?(change) || start_time_removed?(change) + session_removed_row(@session_removed, change) + live_drop(session: change[:object], sheet: @participants_add_drop) if live + next + end + + if change[:changes]['room_id'] + session_room_change_row(@session_room_changed, change) + end + + if change[:changes]['start_time'] + session_time_change_row(@session_time_changed, change) end end @@ -81,14 +82,15 @@ def check_sessions_changed(changes:, live:) session_id = check_status_change(change: change, live: live) if session_id - state_change_sessions << session_id #change[:object].id - else - if change[:changes]['title'] - session_title_change_row(@session_title_changed, change) - end - if change[:changes]['description'] - session_description_change_row(@session_description_changed, change) - end + state_change_sessions << session_id + next + end + + if change[:changes]['title'] + session_title_change_row(@session_title_changed, change) + end + if change[:changes]['description'] + session_description_change_row(@session_description_changed, change) end end end @@ -96,6 +98,22 @@ def check_sessions_changed(changes:, live:) return state_change_sessions end + def room_added?(change) + !change[:changes]['room_id'][0] && change[:changes]['room_id'][1] + end + + def start_time_added?(change) + !change[:changes]['start_time'][0] && change[:changes]['start_time'][1] + end + + def room_removed?(change) + change[:changes]['room_id'][0] && !change[:changes]['room_id'][1] + end + + def start_time_removed?(change) + change[:changes]['start_time'][0] && !change[:changes]['start_time'][1] + end + def check_assignments_changed(changes:, state_change_sessions:) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') @@ -103,14 +121,11 @@ def check_assignments_changed(changes:, state_change_sessions:) fully_dropped = [] changes.each do |id, change| - changed_assignment = change[:object] - changed_assignment ||= SessionAssignment.find change[:session_assignment_id] - next if state_change_sessions.include? changed_assignment.session_id + next if state_change_sessions.include? change[:item_id] - session = changed_assignment.session if changed_assignment.session - session ||= Session.find changed_assignment.session_id - - # Rails.logger.debug "******** Assignment changes #{change}" + changed_assignment = change[:object] + changed_assignment ||= SessionAssignment.find(change[:item_id]) if SessionAssignment.exists?(change[:item_id]) + session = changed_assignment.session # Participants add/drop if change[:changes]['session_assignment_role_type_id'] && change[:event] != 'destroy' @@ -130,7 +145,8 @@ def check_assignments_changed(changes:, state_change_sessions:) changed_assignment.person.published_name, ] ) - if changed_assignment.person.sessions.scheduled.count == 0 + + if ['declined', 'rejected'].include? changed_assignment.person.con_state fully_dropped.append [change[:object].person.published_name] end end @@ -144,7 +160,7 @@ def check_assignments_changed(changes:, state_change_sessions:) changed_assignment.person.published_name, ] ) - if changed_assignment.person.sessions.scheduled.count == 0 + if ['declined', 'rejected'].include? changed_assignment.person.con_state fully_dropped.append [changed_assignment.person.published_name] end end @@ -159,7 +175,7 @@ def check_status_change(change:, live: false) return unless change[:changes]['status'] return if ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) - # Rails.logger.debug "********* STATUS CHANGE ....." + # Rails.logger.debug "********* STATUS CHANGE ..... #{change[:changes]['status']}" if ['draft', 'dropped'].include?(change[:changes]['status'][1]) if live return unless change[:object].published_session @@ -176,6 +192,7 @@ def check_status_change(change:, live: false) end if ['draft', 'dropped'].include?(change[:changes]['status'][0]) + # Rails.logger.debug "********* STATUS CHANGE ..... ADDD #{live}" session_added_row(@session_added, change) if live live_add(session: change[:object], sheet: @participants_add_drop) From bc6d42c136fac08e64a2e016ecf814653f5a9087 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 08:05:25 -0400 Subject: [PATCH 04/45] plan-712, plan-713, plan-714, plan-715 fixes for pub diffs --- .../reports/schedule_reports_controller.rb | 33 +++++++++++++------ app/services/change_service.rb | 5 +-- 2 files changed, 24 insertions(+), 14 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 64e9fcd86..bf21849ad 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -95,6 +95,8 @@ def check_sessions_changed(changes:, live:) end end + Rails.logger.debug "*********** ST #{state_change_sessions}" + return state_change_sessions end @@ -121,11 +123,22 @@ def check_assignments_changed(changes:, state_change_sessions:) fully_dropped = [] changes.each do |id, change| - next if state_change_sessions.include? change[:item_id] - changed_assignment = change[:object] changed_assignment ||= SessionAssignment.find(change[:item_id]) if SessionAssignment.exists?(change[:item_id]) - session = changed_assignment.session + + next if state_change_sessions.include?(changed_assignment.session_id || changed_assignment.published_session_id) + + session = if changed_assignment + changed_assignment.session + else + session_id = change[:published_session_id] || change[:session_id] + Session.find session_id if Session.exists? session_id + end + next unless session + + person = change[:object].person + person ||= Session.find change[:person_id] if Session.exists? change[:person_id] + next unless person # Participants add/drop if change[:changes]['session_assignment_role_type_id'] && change[:event] != 'destroy' @@ -135,19 +148,19 @@ def check_assignments_changed(changes:, state_change_sessions:) [ session.title, '', - changed_assignment.person.published_name + person.published_name ] ) elsif (roles.include?(change[:changes]['session_assignment_role_type_id'][0])) @participants_add_drop.append_row( [ session.title, - changed_assignment.person.published_name, + person.published_name, ] ) - if ['declined', 'rejected'].include? changed_assignment.person.con_state - fully_dropped.append [change[:object].person.published_name] + if ['declined', 'rejected'].include? person.con_state + fully_dropped.append [person.published_name] end end end @@ -157,11 +170,11 @@ def check_assignments_changed(changes:, state_change_sessions:) @participants_add_drop.append_row( [ session.title, - changed_assignment.person.published_name, + person.published_name, ] ) - if ['declined', 'rejected'].include? changed_assignment.person.con_state - fully_dropped.append [changed_assignment.person.published_name] + if ['declined', 'rejected'].include? person.con_state + fully_dropped.append [person.published_name] end end end diff --git a/app/services/change_service.rb b/app/services/change_service.rb index 1d5921d99..bb7f47724 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -47,8 +47,6 @@ def self.get_changes(clazz:, type:, from:, to:, publishable_session_ids: nil) audits = audits.where("created_at >= ?", from) if from audits = audits.where("created_at <= ?", to) if to - # Rails.logger.debug "**** AUDITS #{audits.count}" - grouped_audits = audits.group_by {|a| a.item_id} grouped_audits.each do |key, item_audits| @@ -64,12 +62,11 @@ def self.get_changes(clazz:, type:, from:, to:, publishable_session_ids: nil) if publishable_session_ids next unless publishable_session_ids.include?(obj.session_id) end - changes[key] = {event: audit.event, object: obj, changes: audit.object_changes} + changes[key] = {item_id: audit.item_id, event: audit.event, object: obj, changes: audit.object_changes} end end end - # TODO: any way we can order by the session title ??? changes end From 861ff5b950f29f606ff7f5c396057cd1284cd188 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 09:46:59 -0400 Subject: [PATCH 05/45] want stack trace of errors in log --- app/controllers/application_controller.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 8ae0032ea..bbba2594d 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -92,8 +92,8 @@ def configure_permitted_parameters def render_jsonapi_internal_server_error(exception) # Rails.logger.error "**** INTERNAL ERROR #{exception.class}" - Rails.logger.error exception.message if Rails.env.development? - Rails.logger.error exception.backtrace.join("\n\t") if Rails.env.development? + Rails.logger.error exception.message #if Rails.env.development? + Rails.logger.error exception.backtrace.join("\n\t") #if Rails.env.development? # NOTE: if we have a central log put it in here super(exception) end From ed20e9d67f666cf52fa1cbef078371df9007e1c7 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 10:03:33 -0400 Subject: [PATCH 06/45] fix test for room anf time change --- app/controllers/reports/schedule_reports_controller.rb | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index bf21849ad..5770edeee 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -101,18 +101,26 @@ def check_sessions_changed(changes:, live:) end def room_added?(change) + return false unless change[:changes] && change[:changes]['room_id'] + !change[:changes]['room_id'][0] && change[:changes]['room_id'][1] end def start_time_added?(change) + return false unless change[:changes] && change[:changes]['start_time'] + !change[:changes]['start_time'][0] && change[:changes]['start_time'][1] end def room_removed?(change) + return false unless change[:changes] && change[:changes]['room_id'] + change[:changes]['room_id'][0] && !change[:changes]['room_id'][1] end def start_time_removed?(change) + return false unless change[:changes] && change[:changes]['start_time'] + change[:changes]['start_time'][0] && !change[:changes]['start_time'][1] end From 79d086dfc05fd3c7b0e1e25eaabb36c3a46983f8 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 10:04:48 -0400 Subject: [PATCH 07/45] remove log statement --- app/controllers/reports/schedule_reports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 5770edeee..29383bbe6 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -95,7 +95,7 @@ def check_sessions_changed(changes:, live:) end end - Rails.logger.debug "*********** ST #{state_change_sessions}" + # Rails.logger.debug "*********** ST #{state_change_sessions}" return state_change_sessions end From 8774d9e3f05bded37003bb7397a4f5956ecc70ad Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 17:17:06 -0400 Subject: [PATCH 08/45] PLAN-719 fix diff with current --- .../reports/schedule_reports_controller.rb | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 29383bbe6..d1eaf53ce 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -55,8 +55,10 @@ def check_sessions_changed(changes:, live:) changes.values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| next unless change[:object] - if (change[:changes]['room_id'] || change[:changes]['start_time']) && !change[:changes]['status'] - # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]['status']} " + if (change[:changes]['room_id'] || change[:changes]['start_time']) #&& !change[:changes]['status'] + next if ignore_session_status_change?(change: change) + + # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " if room_added?(change) || start_time_added?(change) session_added_row(@session_added, change) live_add(session: change[:object], sheet: @participants_add_drop) if live @@ -194,7 +196,7 @@ def check_assignments_changed(changes:, state_change_sessions:) def check_status_change(change:, live: false) # Rails.logger.debug "********* STATUS CHANGE" return unless change[:changes]['status'] - return if ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) + return if ignore_session_status_change?(change: change) # Rails.logger.debug "********* STATUS CHANGE ..... #{change[:changes]['status']}" if ['draft', 'dropped'].include?(change[:changes]['status'][1]) @@ -225,6 +227,10 @@ def check_status_change(change:, live: false) end end + def ignore_session_status_change?(change:) + ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) + end + def init_sheets(workbook:) @session_time_changed = workbook.add_worksheet("Session Time Changed") From 79da39c37a4de9fda27eaee8c3567e4b5fe620ec Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 17:47:46 -0400 Subject: [PATCH 09/45] fixes for pub diffs --- .../reports/schedule_reports_controller.rb | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index d1eaf53ce..ac01d9aa9 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -56,7 +56,7 @@ def check_sessions_changed(changes:, live:) next unless change[:object] if (change[:changes]['room_id'] || change[:changes]['start_time']) #&& !change[:changes]['status'] - next if ignore_session_status_change?(change: change) + next if change[:changes]['status'] && ignore_session_status_change?(change: change) # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " if room_added?(change) || start_time_added?(change) @@ -134,20 +134,17 @@ def check_assignments_changed(changes:, state_change_sessions:) fully_dropped = [] changes.each do |id, change| changed_assignment = change[:object] - changed_assignment ||= SessionAssignment.find(change[:item_id]) if SessionAssignment.exists?(change[:item_id]) + changed_assignment ||= SessionAssignment.find(id) if SessionAssignment.exists?(id) next if state_change_sessions.include?(changed_assignment.session_id || changed_assignment.published_session_id) - session = if changed_assignment - changed_assignment.session - else - session_id = change[:published_session_id] || change[:session_id] - Session.find session_id if Session.exists? session_id - end + session = changed_assignment.session + session_id = change[:object][:published_session_id] || change[:object][:session_id] + session ||= Session.find session_id if Session.exists? session_id next unless session person = change[:object].person - person ||= Session.find change[:person_id] if Session.exists? change[:person_id] + person ||= Person.find change[:object][:person_id] if Person.exists? change[:object][:person_id] next unless person # Participants add/drop From 65690fdb0e617f48123517c8165e1a9837c7bc57 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 18:41:49 -0400 Subject: [PATCH 10/45] fix for pub diffs --- app/controllers/reports/schedule_reports_controller.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index ac01d9aa9..ecf964a23 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -136,6 +136,7 @@ def check_assignments_changed(changes:, state_change_sessions:) changed_assignment = change[:object] changed_assignment ||= SessionAssignment.find(id) if SessionAssignment.exists?(id) + next unless changed_assignment next if state_change_sessions.include?(changed_assignment.session_id || changed_assignment.published_session_id) session = changed_assignment.session @@ -143,8 +144,8 @@ def check_assignments_changed(changes:, state_change_sessions:) session ||= Session.find session_id if Session.exists? session_id next unless session - person = change[:object].person - person ||= Person.find change[:object][:person_id] if Person.exists? change[:object][:person_id] + person ||= changed_assignment.person + # person ||= Person.find change[:object][:person_id] if Person.exists? change[:object][:person_id] next unless person # Participants add/drop From a54464c45332b9ce2bdf0d9beeaf3990ab004de3 Mon Sep 17 00:00:00 2001 From: Henry Date: Mon, 15 Aug 2022 20:00:31 -0400 Subject: [PATCH 11/45] fix for missing session test --- app/controllers/reports/schedule_reports_controller.rb | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index ecf964a23..576d5e479 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -140,8 +140,10 @@ def check_assignments_changed(changes:, state_change_sessions:) next if state_change_sessions.include?(changed_assignment.session_id || changed_assignment.published_session_id) session = changed_assignment.session - session_id = change[:object][:published_session_id] || change[:object][:session_id] - session ||= Session.find session_id if Session.exists? session_id + if !session && change[:object] + session_id = change[:object][:published_session_id] || change[:object][:session_id] + session ||= Session.find session_id if Session.exists? session_id + end next unless session person ||= changed_assignment.person From 59642fc66e5f2a7ca7d3e9e9771b90a6d7334455 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Tue, 16 Aug 2022 08:53:00 -0400 Subject: [PATCH 12/45] fix hash links --- app/javascript/app.vue | 4 ++- app/javascript/components/hash_link.vue | 21 +++++++++++++++ app/javascript/reports/reports_screen.vue | 32 +++++++++++++---------- app/javascript/shared/hash-links.mixin.js | 9 +++++++ 4 files changed, 51 insertions(+), 15 deletions(-) create mode 100644 app/javascript/components/hash_link.vue create mode 100644 app/javascript/shared/hash-links.mixin.js diff --git a/app/javascript/app.vue b/app/javascript/app.vue index ceb044aaa..668afc55c 100644 --- a/app/javascript/app.vue +++ b/app/javascript/app.vue @@ -32,6 +32,7 @@ import VueCal from 'vue-cal' import 'vue-cal/dist/vuecal.css' import { mapState, mapActions } from 'vuex'; import { FETCH_WORKFLOWS } from '@/store/schedule_workflow'; +import { hashLinksMixin } from './shared/hash-links.mixin'; extend('email', email); extend('numeric', numeric); @@ -54,7 +55,7 @@ export default { BottomNavbar, SignAgreements }, - mixins: [personSessionMixin, settingsMixin], + mixins: [personSessionMixin, settingsMixin, hashLinksMixin], data() { return { showOverlay: false @@ -83,6 +84,7 @@ export default { this.fetchSettings(); // fetch the schedule state too this.fetchScheduleWorkflows(); + setTimeout(() => this.scrollFix(this.$route.hash), 1) } } diff --git a/app/javascript/components/hash_link.vue b/app/javascript/components/hash_link.vue new file mode 100644 index 000000000..53a606806 --- /dev/null +++ b/app/javascript/components/hash_link.vue @@ -0,0 +1,21 @@ + + + + + diff --git a/app/javascript/reports/reports_screen.vue b/app/javascript/reports/reports_screen.vue index 669d09a9d..10f348b80 100644 --- a/app/javascript/reports/reports_screen.vue +++ b/app/javascript/reports/reports_screen.vue @@ -2,11 +2,11 @@

These are interim reports.

Participants
    @@ -182,14 +182,6 @@ Session data included: all sessions

    -
  • - Daily Grid -

    - Description: Session information for daily grid, one line per session
    - Fields: Session title, area(s) of session, session format, session start time, session duration, session room
    - Session data included: all scheduled sessions that are visible and published -

    -
  • Scheduled Sessions Streamed and/or Recorded

    @@ -289,7 +281,7 @@ Schedule by Participant

    Description: Schedule for each participant, one line per person and session
    - Fields: Person name, publishes name, participant status, session title, area(s) of session, session start time, room, moderator (y/n), invisible participant (y/n)
    + Fields: Person name, published name, participant status, session title, area(s) of session, session start time, room, moderator (y/n), invisible participant (y/n)
    Person data included: moderators, participants, invisible participants

  • @@ -314,6 +306,14 @@ Person data included: moderators, participants, invisible participants

    +
  • + Daily Grid +

    + Description: Session information for daily grid, one line per session
    + Fields: Session title, area(s) of session, session format, session start time, session duration, session room
    + Session data included: all scheduled sessions that are visible and published +

    +
@@ -321,9 +321,13 @@ - - diff --git a/app/javascript/shared/hash-links.mixin.js b/app/javascript/shared/hash-links.mixin.js deleted file mode 100644 index f82610d4b..000000000 --- a/app/javascript/shared/hash-links.mixin.js +++ /dev/null @@ -1,9 +0,0 @@ -export const hashLinksMixin = { - methods: { - scrollFix: function(hashbang) { - location.hash = hashbang; - } - } -} - -export default hashLinksMixin; From ba4973ae2cef0911a5a08272f142bcdc19d4b808 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Wed, 17 Aug 2022 08:57:53 -0400 Subject: [PATCH 16/45] remove extra line --- app/javascript/app.vue | 1 - 1 file changed, 1 deletion(-) diff --git a/app/javascript/app.vue b/app/javascript/app.vue index e12c2e877..ceb044aaa 100644 --- a/app/javascript/app.vue +++ b/app/javascript/app.vue @@ -83,7 +83,6 @@ export default { this.fetchSettings(); // fetch the schedule state too this.fetchScheduleWorkflows(); - setTimeout(() => this.scrollFix(this.$route.hash), 1) } } From 6fb2390f724369501c4cf70ec337c626f52845a4 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 17 Aug 2022 13:53:10 -0400 Subject: [PATCH 17/45] PLAN-727 cache for conclar requests, will reduce load on Plano. Cache responses for up to 10 mins.... --- Gemfile | 1 + Gemfile.lock | 49 ++++++++++++++------------ app/controllers/schedule_controller.rb | 11 ++++++ config/environments/production.rb | 2 +- config/environments/staging.rb | 2 +- 5 files changed, 40 insertions(+), 25 deletions(-) diff --git a/Gemfile b/Gemfile index e96be9d3c..060ea8618 100644 --- a/Gemfile +++ b/Gemfile @@ -9,6 +9,7 @@ gem 'rails', '~> 6.1' #, '>= 6.0.3.2' gem 'pg', '>= 0.18', '< 2.0' gem 'activerecord-postgres_enum' +gem 'actionpack-action_caching' # Use Puma as the app server gem 'puma', '>= 5.0' diff --git a/Gemfile.lock b/Gemfile.lock index 6e8761bad..78255a94c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -1,7 +1,7 @@ GEM remote: https://rubygems.org/ specs: - aasm (5.2.0) + aasm (5.3.0) concurrent-ruby (~> 1.0) actioncable (6.1.6.1) actionpack (= 6.1.6.1) @@ -29,6 +29,8 @@ GEM rack-test (>= 0.6.3) rails-dom-testing (~> 2.0) rails-html-sanitizer (~> 1.0, >= 1.2.0) + actionpack-action_caching (1.2.2) + actionpack (>= 4.0.0) actiontext (6.1.6.1) actionpack (= 6.1.6.1) activerecord (= 6.1.6.1) @@ -77,9 +79,9 @@ GEM ast (2.4.2) bcrypt (3.1.18) bindex (0.8.1) - bootsnap (1.12.0) + bootsnap (1.13.0) msgpack (~> 1.2) - brakeman (5.2.3) + brakeman (5.3.1) builder (3.2.4) bundler-audit (0.9.1) bundler (>= 1.2.0, < 3) @@ -115,7 +117,7 @@ GEM em-websocket (0.5.3) eventmachine (>= 0.12.9) http_parser.rb (~> 0) - erubi (1.10.0) + erubi (1.11.0) et-orbi (1.2.7) tzinfo eventmachine (1.2.7) @@ -124,7 +126,7 @@ GEM factory_bot_rails (6.2.0) factory_bot (~> 6.2.0) railties (>= 5.0.0) - faker (2.21.0) + faker (2.22.0) i18n (>= 1.8.11, < 2) fast_excel (0.4.0) ffi (> 1.9, < 2) @@ -190,32 +192,32 @@ GEM method_source (1.0.0) mini_mime (1.1.2) mini_portile2 (2.8.0) - minitest (5.16.2) - msgpack (1.5.3) + minitest (5.16.3) + msgpack (1.5.4) multi_json (1.15.0) nenv (0.3.0) nilify_blanks (1.4.0) activerecord (>= 4.0.0) activesupport (>= 4.0.0) nio4r (2.5.8) - nokogiri (1.13.7) + nokogiri (1.13.8) mini_portile2 (~> 2.8.0) racc (~> 1.4) - nokogiri (1.13.7-x86_64-darwin) + nokogiri (1.13.8-x86_64-darwin) racc (~> 1.4) - nokogiri (1.13.7-x86_64-linux) + nokogiri (1.13.8-x86_64-linux) racc (~> 1.4) notiffany (0.1.3) nenv (~> 0.1) shellany (~> 0.0) orm_adapter (0.5.0) - paper_trail (12.3.0) + paper_trail (13.0.0) activerecord (>= 5.2) request_store (~> 1.1) parallel (1.22.1) - parser (3.1.2.0) + parser (3.1.2.1) ast (~> 2.4.1) - pg (1.4.1) + pg (1.4.3) pry (0.14.1) coderay (~> 1.1) method_source (~> 1.0) @@ -304,17 +306,17 @@ GEM rspec-mocks (~> 3.10) rspec-support (~> 3.10) rspec-support (3.11.0) - rubocop (1.31.2) + rubocop (1.35.0) json (~> 2.3) parallel (~> 1.10) - parser (>= 3.1.0.0) + parser (>= 3.1.2.1) rainbow (>= 2.2.2, < 4.0) regexp_parser (>= 1.8, < 3.0) rexml (>= 3.2.5, < 4.0) - rubocop-ast (>= 1.18.0, < 2.0) + rubocop-ast (>= 1.20.1, < 2.0) ruby-progressbar (~> 1.7) unicode-display_width (>= 1.4.0, < 3.0) - rubocop-ast (1.19.1) + rubocop-ast (1.21.0) parser (>= 3.1.1.0) ruby-progressbar (1.11.0) ruby_audit (2.1.0) @@ -334,17 +336,17 @@ GEM tilt seedbank (0.5.0) rake (>= 10.0) - selenium-webdriver (4.3.0) + selenium-webdriver (4.4.0) childprocess (>= 0.5, < 5.0) rexml (~> 3.2, >= 3.2.5) rubyzip (>= 1.2.2, < 3.0) websocket (~> 1.0) semantic_range (3.0.0) shellany (0.0.1) - sidekiq (6.5.1) + sidekiq (6.5.4) connection_pool (>= 2.2.2) rack (~> 2.0) - redis (>= 4.2.0) + redis (>= 4.5.0) sidekiq-scheduler (4.0.2) redis (>= 4.2.0) rufus-scheduler (~> 3.2) @@ -364,10 +366,10 @@ GEM activesupport (>= 5.2) sprockets (>= 3.0.0) thor (1.2.1) - tilt (2.0.10) - truemail (2.7.3) + tilt (2.0.11) + truemail (2.7.4) simpleidn (~> 0.2.1) - tzinfo (2.0.4) + tzinfo (2.0.5) concurrent-ruby (~> 1.0) unf (0.1.4) unf_ext @@ -407,6 +409,7 @@ PLATFORMS DEPENDENCIES aasm + actionpack-action_caching active_model_serializers (~> 0.10.0) activerecord-postgres_enum acts-as-taggable-on (~> 9.0) diff --git a/app/controllers/schedule_controller.rb b/app/controllers/schedule_controller.rb index 47f8b9717..6c3d7581a 100644 --- a/app/controllers/schedule_controller.rb +++ b/app/controllers/schedule_controller.rb @@ -2,6 +2,13 @@ class ScheduleController < ApplicationController skip_before_action :check_up, :authenticate_person!, only: [:index, :participants] + # Put in a memory cache and cache header for the conclar data + before_action :setup_cache_header + + # Cache index and particpant request for 10 minutes and prevent dog pile by allowing 1 minute regen + caches_action :index, expires_in: 10.minute, race_condition_ttl: 1.minute + caches_action :participants, expires_in: 10.minute, race_condition_ttl: 1.minute + # 1. If prod always use the published schedule # 2. If staging or dev use published - if no published then use the live for testing # 3. cache mechanism (cache can be popultaed as part of the publish) @@ -35,4 +42,8 @@ def participants content_type: 'application/json' end end + + def setup_cache_header + response.headers["Cache-Control"] = "public, max-age=#{10.minutes.to_i}" + end end diff --git a/config/environments/production.rb b/config/environments/production.rb index 9563dfb53..217c0f76a 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -54,7 +54,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - # config.cache_store = :mem_cache_store + config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). config.active_job.queue_adapter = :sidekiq diff --git a/config/environments/staging.rb b/config/environments/staging.rb index d1b743c60..de4c2acf7 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -54,7 +54,7 @@ config.log_tags = [ :request_id ] # Use a different cache store in staging. - # config.cache_store = :mem_cache_store + config.cache_store = :mem_cache_store # Use a real queuing backend for Active Job (and separate queues per environment). config.active_job.queue_adapter = :sidekiq From 3e3cdcff6b02404a7b1d5e4b32296b63ad5b67f0 Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 17 Aug 2022 15:46:53 -0400 Subject: [PATCH 18/45] PLAN-724 various fixes to diff logic --- .../publication_dates_controller.rb | 20 +++++---- .../reports/schedule_reports_controller.rb | 43 +++++++++---------- app/services/change_service.rb | 9 +++- 3 files changed, 38 insertions(+), 34 deletions(-) diff --git a/app/controllers/publication_dates_controller.rb b/app/controllers/publication_dates_controller.rb index 971d4b442..3048de63e 100644 --- a/app/controllers/publication_dates_controller.rb +++ b/app/controllers/publication_dates_controller.rb @@ -7,18 +7,20 @@ class PublicationDatesController < ResourceController def reset # Make sure that people can not publish etc while we clean up - PublicationStatus.last.update(status: 'inprogress') + if PublicationStatus.last + PublicationStatus.last.update(status: 'inprogress') - # Get rid of published data first - PublishedSession.destroy_all + # Get rid of published data first + PublishedSession.destroy_all - # Then get rid of the audit - Audit::PublishedSessionVersion.delete_all + # Then get rid of the audit + Audit::PublishedSessionVersion.delete_all - # Then remove caches, dates, and status - PublishSnapshot.delete_all - PublicationDate.delete_all - PublicationStatus.delete_all + # Then remove caches, dates, and status + PublishSnapshot.delete_all + PublicationDate.delete_all + PublicationStatus.delete_all + end render status: :ok, json: { message: 'publication reset' }.to_json, diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 576d5e479..0316e525e 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -55,8 +55,13 @@ def check_sessions_changed(changes:, live:) changes.values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| next unless change[:object] + if change[:object] && session_status_change_to_publishable?(change: change) || session_status_change_to_drop?(change: change) + state_change_sessions << change[:object].id + end + if (change[:changes]['room_id'] || change[:changes]['start_time']) #&& !change[:changes]['status'] - next if change[:changes]['status'] && ignore_session_status_change?(change: change) + next if ignore_session_status_change?(change: change) + next if !change[:changes]['status'] && ['draft', 'dropped'].include?(change[:object].status) # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " if room_added?(change) || start_time_added?(change) @@ -81,12 +86,7 @@ def check_sessions_changed(changes:, live:) end if change[:object].start_time && change[:object].room_id - session_id = check_status_change(change: change, live: live) - - if session_id - state_change_sessions << session_id - next - end + check_status_change(change: change, live: live) if change[:changes]['title'] session_title_change_row(@session_title_changed, change) @@ -98,7 +98,6 @@ def check_sessions_changed(changes:, live:) end # Rails.logger.debug "*********** ST #{state_change_sessions}" - return state_change_sessions end @@ -194,43 +193,41 @@ def check_assignments_changed(changes:, state_change_sessions:) end def check_status_change(change:, live: false) - # Rails.logger.debug "********* STATUS CHANGE" return unless change[:changes]['status'] return if ignore_session_status_change?(change: change) - # Rails.logger.debug "********* STATUS CHANGE ..... #{change[:changes]['status']}" - if ['draft', 'dropped'].include?(change[:changes]['status'][1]) + if session_status_change_to_drop?(change: change) if live return unless change[:object].published_session - session_removed_row(@session_removed, change) live_drop(session: change[:object], sheet: @participants_add_drop) - - return change[:object].id - else - session_removed_row(@session_removed, change) end + session_removed_row(@session_removed, change) + return end - if ['draft', 'dropped'].include?(change[:changes]['status'][0]) + if session_status_change_to_publishable?(change: change) # Rails.logger.debug "********* STATUS CHANGE ..... ADDD #{live}" session_added_row(@session_added, change) - if live - live_add(session: change[:object], sheet: @participants_add_drop) - - return change[:object].id - end + live_add(session: change[:object], sheet: @participants_add_drop) if live return end end def ignore_session_status_change?(change:) - ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) + change[:changes]['status'] && ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['draft', 'dropped'].include?(change[:changes]['status'][1]) end + def session_status_change_to_publishable?(change:) + change[:changes]['status'] && ['draft', 'dropped'].include?(change[:changes]['status'][0]) && ['reviewed', 'revised'].include?(change[:changes]['status'][1]) + end + + def session_status_change_to_drop?(change:) + change[:changes]['status'] && ['draft', 'dropped'].include?(change[:changes]['status'][1]) && ['reviewed', 'revised'].include?(change[:changes]['status'][0]) + end def init_sheets(workbook:) @session_time_changed = workbook.add_worksheet("Session Time Changed") diff --git a/app/services/change_service.rb b/app/services/change_service.rb index bb7f47724..e485aad8b 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -57,8 +57,13 @@ def self.get_changes(clazz:, type:, from:, to:, publishable_session_ids: nil) if changes[key] changes[key][:changes] = self.merge_change_set(to: changes[key][:changes], from: audit.object_changes) else - obj = type.find(audit.item_id) if audit.event != 'destroy' && type.exists?(audit.item_id) - obj ||= audit.reify + # Get the old version of the object + obj = if audit.event == 'create' + type.find(audit.item_id) if type.exists?(audit.item_id) + else + audit.reify + end + # obj = audit.reify if publishable_session_ids next unless publishable_session_ids.include?(obj.session_id) end From aed863a6f3b5dabdc33070f2716ed0713169188f Mon Sep 17 00:00:00 2001 From: Henry Date: Wed, 17 Aug 2022 19:12:54 -0400 Subject: [PATCH 19/45] fix for cache config. Use memory for now as we do no cache much --- config/environments/production.rb | 6 +++++- config/environments/staging.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 217c0f76a..9d45caf19 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -54,7 +54,11 @@ config.log_tags = [ :request_id ] # Use a different cache store in production. - config.cache_store = :mem_cache_store + # config.cache_store = :mem_cache_store + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{10.minutes.to_i}" + } # Use a real queuing backend for Active Job (and separate queues per environment). config.active_job.queue_adapter = :sidekiq diff --git a/config/environments/staging.rb b/config/environments/staging.rb index de4c2acf7..1bb4f439b 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -54,7 +54,11 @@ config.log_tags = [ :request_id ] # Use a different cache store in staging. - config.cache_store = :mem_cache_store + # config.cache_store = :mem_cache_store + config.cache_store = :memory_store + config.public_file_server.headers = { + 'Cache-Control' => "public, max-age=#{10.minutes.to_i}" + } # Use a real queuing backend for Active Job (and separate queues per environment). config.active_job.queue_adapter = :sidekiq From e362f5701ee270e042db22f25e46931f340d2de0 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 09:17:54 -0400 Subject: [PATCH 20/45] handle case of new scheduled sessions --- .../reports/schedule_reports_controller.rb | 22 +++++++++++-------- app/services/change_service.rb | 2 +- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 0316e525e..1cbbc6846 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -339,18 +339,22 @@ def session_added_row(sheet, change) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') - # If this is Session and it is added then so are the people + object = change[:object] + # If it is an add and we have the reify before the time and room get the latest version of the object + if !change[:object].start_time || !change[:object].room_id + object = change[:item_type].constantize.find change[:item_id].id + end sheet.append_row( [ - change[:object].title, - change[:object].description, - change[:object].format&.name, - change[:object].areas.collect(&:name).join("; "), - FastExcel.date_num(change[:object].start_time, change[:object].start_time.in_time_zone.utc_offset), - change[:object].room&.name, - change[:object].participant_assignments.where("session_assignment_role_type_id = ?", moderator).collect{|a| a.person.published_name}.join("; "), - change[:object].participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") + object.title, + object.description, + object.format&.name, + object.areas.collect(&:name).join("; "), + FastExcel.date_num(object.start_time, object.start_time.in_time_zone.utc_offset), + object.room&.name, + object.participant_assignments.where("session_assignment_role_type_id = ?", moderator).collect{|a| a.person.published_name}.join("; "), + object.participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") ], [ nil, nil, nil, nil, @date_time_style, nil, nil, nil diff --git a/app/services/change_service.rb b/app/services/change_service.rb index e485aad8b..5fc47c591 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -67,7 +67,7 @@ def self.get_changes(clazz:, type:, from:, to:, publishable_session_ids: nil) if publishable_session_ids next unless publishable_session_ids.include?(obj.session_id) end - changes[key] = {item_id: audit.item_id, event: audit.event, object: obj, changes: audit.object_changes} + changes[key] = {item_id: audit.item_id, item_type: audit.item_type, event: audit.event, object: obj, changes: audit.object_changes} end end end From 6f0d4a0554f540cb4646501bcc8cab1276ca7129 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 09:35:38 -0400 Subject: [PATCH 21/45] fix typo (should not call id on id) --- app/controllers/reports/schedule_reports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 1cbbc6846..0099d7458 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -342,7 +342,7 @@ def session_added_row(sheet, change) object = change[:object] # If it is an add and we have the reify before the time and room get the latest version of the object if !change[:object].start_time || !change[:object].room_id - object = change[:item_type].constantize.find change[:item_id].id + object = change[:item_type].constantize.find change[:item_id] end sheet.append_row( From b25b4038cc8688d8fdd90fbb39e0bf56c95e13e1 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 13:29:15 -0400 Subject: [PATCH 22/45] fix pub to pub diff status check --- app/controllers/reports/schedule_reports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 0099d7458..c518b0413 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -61,7 +61,7 @@ def check_sessions_changed(changes:, live:) if (change[:changes]['room_id'] || change[:changes]['start_time']) #&& !change[:changes]['status'] next if ignore_session_status_change?(change: change) - next if !change[:changes]['status'] && ['draft', 'dropped'].include?(change[:object].status) + next if live && !change[:changes]['status'] && ['draft', 'dropped'].include?(change[:object].status) # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " if room_added?(change) || start_time_added?(change) From b93c6632623885c26ece4efd588f319e51047839 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 17:21:51 -0400 Subject: [PATCH 23/45] fix diff issue for current --- .../reports/schedule_reports_controller.rb | 24 ++++++++++++------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index c518b0413..3b7e6e888 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -64,27 +64,32 @@ def check_sessions_changed(changes:, live:) next if live && !change[:changes]['status'] && ['draft', 'dropped'].include?(change[:object].status) # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " + # If either room or time was added to the session if room_added?(change) || start_time_added?(change) session_added_row(@session_added, change) - live_add(session: change[:object], sheet: @participants_add_drop) if live + live_add(change: change, sheet: @participants_add_drop) if live next end + # If either room or time was removed to the session if room_removed?(change) || start_time_removed?(change) session_removed_row(@session_removed, change) live_drop(session: change[:object], sheet: @participants_add_drop) if live next end + # If the room was changed if change[:changes]['room_id'] session_room_change_row(@session_room_changed, change) end + # If the time was changed if change[:changes]['start_time'] session_time_change_row(@session_time_changed, change) end end + # If the object is scheduked and title or description was changed if change[:object].start_time && change[:object].room_id check_status_change(change: change, live: live) @@ -211,7 +216,7 @@ def check_status_change(change:, live: false) if session_status_change_to_publishable?(change: change) # Rails.logger.debug "********* STATUS CHANGE ..... ADDD #{live}" session_added_row(@session_added, change) - live_add(session: change[:object], sheet: @participants_add_drop) if live + live_add(session: change, sheet: @participants_add_drop) if live return end @@ -255,11 +260,14 @@ def tab_headers @participants_fully_dropped.append_row(['Participant Dropped']) end - def live_add(session:, sheet:) - session.participant_assignments.each do |sa| + def live_add(change:, sheet:) + object = change[:item_type].constantize.find change[:item_id] + return unless object.start_time && object.room_id + + object.participant_assignments.each do |sa| sheet.append_row( [ - session.title, + object.title, '', sa.person.published_name, ] @@ -339,11 +347,9 @@ def session_added_row(sheet, change) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') - object = change[:object] # If it is an add and we have the reify before the time and room get the latest version of the object - if !change[:object].start_time || !change[:object].room_id - object = change[:item_type].constantize.find change[:item_id] - end + object = change[:item_type].constantize.find change[:item_id] + return unless object.start_time && object.room_id sheet.append_row( [ From 10e13379fc49bfeb870775b711f11b1430ead9ba Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 20:16:08 -0400 Subject: [PATCH 24/45] fix code to determine who dropped --- .../reports/schedule_reports_controller.rb | 21 +++++++------------ app/services/change_service.rb | 11 ++++++++++ 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index c518b0413..26182c5af 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -23,6 +23,8 @@ def schedule_diff live = true ChangeService.session_changes(from: from) end + fully_dropped = ChangeService.dropped_people(from: from, to: to) + to ||= Time.now workbook = FastExcel.open(constant_memory: true) @@ -33,10 +35,10 @@ def schedule_diff changes: changes[:sessions], live: live ) - fully_dropped = check_assignments_changed( - changes: changes[:assignments], - state_change_sessions: state_change_sessions - ) + check_assignments_changed( + changes: changes[:assignments], + state_change_sessions: state_change_sessions + ) fully_dropped.uniq.each do |name| @participants_fully_dropped.append_row(name) @@ -130,7 +132,7 @@ def check_assignments_changed(changes:, state_change_sessions:) participant = SessionAssignmentRoleType.find_by(name: 'Participant') roles = [moderator.id, participant.id] - fully_dropped = [] + # fully_dropped = [] changes.each do |id, change| changed_assignment = change[:object] changed_assignment ||= SessionAssignment.find(id) if SessionAssignment.exists?(id) @@ -167,10 +169,6 @@ def check_assignments_changed(changes:, state_change_sessions:) person.published_name, ] ) - - if ['declined', 'rejected'].include? person.con_state - fully_dropped.append [person.published_name] - end end end else @@ -182,14 +180,9 @@ def check_assignments_changed(changes:, state_change_sessions:) person.published_name, ] ) - if ['declined', 'rejected'].include? person.con_state - fully_dropped.append [person.published_name] - end end end end - - return fully_dropped end def check_status_change(change:, live: false) diff --git a/app/services/change_service.rb b/app/services/change_service.rb index 5fc47c591..3075146ed 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -16,6 +16,17 @@ def self.published_changes(from:, to: nil) } end + def self.dropped_people(from:, to: nil) + res = [] + changes = get_changes(clazz: Audit::PersonVersion, type: Person, from: from, to: to) + changes.each do |id, change| + if change[:changes]['con_state'] && ['declined', 'rejected'].include?(change[:changes]['con_state'][1] ) + res.append [change[:object].published_name] + end + end + res.uniq + end + def self.sessions_changed(from:, to: nil) get_changes(clazz: Audit::SessionVersion, type: Session, from: from, to: to) end From 83e8b37fc9d34245426ab36ecdc78aa5191078cf Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 20:18:36 -0400 Subject: [PATCH 25/45] fix param typo --- app/controllers/reports/schedule_reports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 341b2b344..18d5f5fb1 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -209,7 +209,7 @@ def check_status_change(change:, live: false) if session_status_change_to_publishable?(change: change) # Rails.logger.debug "********* STATUS CHANGE ..... ADDD #{live}" session_added_row(@session_added, change) - live_add(session: change, sheet: @participants_add_drop) if live + live_add(change: change, sheet: @participants_add_drop) if live return end From 2fb45cf247b79552930173f7ea1891e65a8d220b Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 20:23:16 -0400 Subject: [PATCH 26/45] ignore declined to drop (and vice versa) in the drop report --- app/services/change_service.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/services/change_service.rb b/app/services/change_service.rb index 3075146ed..69724d4e4 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -21,6 +21,9 @@ def self.dropped_people(from:, to: nil) changes = get_changes(clazz: Audit::PersonVersion, type: Person, from: from, to: to) changes.each do |id, change| if change[:changes]['con_state'] && ['declined', 'rejected'].include?(change[:changes]['con_state'][1] ) + # do not count a "dropped" state to another dropped state + next if ['declined', 'rejected'].include?(change[:changes]['con_state'][0] + res.append [change[:object].published_name] end end From 1e8c7eecfd48c74754eb74b0857cc083379df282 Mon Sep 17 00:00:00 2001 From: Henry Date: Thu, 18 Aug 2022 23:39:54 -0400 Subject: [PATCH 27/45] fix typo --- app/services/change_service.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/services/change_service.rb b/app/services/change_service.rb index 69724d4e4..12b406e29 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -22,7 +22,7 @@ def self.dropped_people(from:, to: nil) changes.each do |id, change| if change[:changes]['con_state'] && ['declined', 'rejected'].include?(change[:changes]['con_state'][1] ) # do not count a "dropped" state to another dropped state - next if ['declined', 'rejected'].include?(change[:changes]['con_state'][0] + next if ['declined', 'rejected'].include?(change[:changes]['con_state'][0]) res.append [change[:object].published_name] end From f3543c7d082aae556ef5bc104a6134a54e2ad353 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Aug 2022 06:33:18 -0400 Subject: [PATCH 28/45] fix for session titles --- .../reports/schedule_reports_controller.rb | 28 ++++++++----------- app/services/change_service.rb | 10 +++++++ 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index 18d5f5fb1..b04607ce7 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -33,11 +33,13 @@ def schedule_diff # Rails.logger.debug "******** CHANGES: #{changes[:sessions]}" state_change_sessions = check_sessions_changed( changes: changes[:sessions], + to: to, live: live ) check_assignments_changed( changes: changes[:assignments], - state_change_sessions: state_change_sessions + state_change_sessions: state_change_sessions, + to: to ) fully_dropped.uniq.each do |name| @@ -52,7 +54,7 @@ def schedule_diff # # # - def check_sessions_changed(changes:, live:) + def check_sessions_changed(changes:, to:, live:) state_change_sessions = [] changes.values.sort{|a,b| (a[:object] ? a[:object].title : '') <=> (b[:object] ? b[:object].title : '')}.each do |change| next unless change[:object] @@ -68,7 +70,7 @@ def check_sessions_changed(changes:, live:) # Rails.logger.debug "******** SESSION ADD/REMOVE #{change[:changes]} " # If either room or time was added to the session if room_added?(change) || start_time_added?(change) - session_added_row(@session_added, change) + session_added_row(@session_added, change, to) live_add(change: change, sheet: @participants_add_drop) if live next end @@ -93,7 +95,7 @@ def check_sessions_changed(changes:, live:) # If the object is scheduked and title or description was changed if change[:object].start_time && change[:object].room_id - check_status_change(change: change, live: live) + check_status_change(change: change, to: to, live: live) if change[:changes]['title'] session_title_change_row(@session_title_changed, change) @@ -132,12 +134,11 @@ def start_time_removed?(change) change[:changes]['start_time'][0] && !change[:changes]['start_time'][1] end - def check_assignments_changed(changes:, state_change_sessions:) + def check_assignments_changed(changes:, state_change_sessions:, to:) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') roles = [moderator.id, participant.id] - # fully_dropped = [] changes.each do |id, change| changed_assignment = change[:object] changed_assignment ||= SessionAssignment.find(id) if SessionAssignment.exists?(id) @@ -145,15 +146,10 @@ def check_assignments_changed(changes:, state_change_sessions:) next unless changed_assignment next if state_change_sessions.include?(changed_assignment.session_id || changed_assignment.published_session_id) - session = changed_assignment.session - if !session && change[:object] - session_id = change[:object][:published_session_id] || change[:object][:session_id] - session ||= Session.find session_id if Session.exists? session_id - end + session = ChangeService.session_as_of(session_id: changed_assignment.session_id, to: to) next unless session person ||= changed_assignment.person - # person ||= Person.find change[:object][:person_id] if Person.exists? change[:object][:person_id] next unless person # Participants add/drop @@ -190,7 +186,7 @@ def check_assignments_changed(changes:, state_change_sessions:) end end - def check_status_change(change:, live: false) + def check_status_change(change:, to:, live: false) return unless change[:changes]['status'] return if ignore_session_status_change?(change: change) @@ -208,7 +204,7 @@ def check_status_change(change:, live: false) if session_status_change_to_publishable?(change: change) # Rails.logger.debug "********* STATUS CHANGE ..... ADDD #{live}" - session_added_row(@session_added, change) + session_added_row(@session_added, change, to) live_add(change: change, sheet: @participants_add_drop) if live return @@ -336,12 +332,12 @@ def session_time_change_row(sheet, change) end # Generate a row for sessions added - def session_added_row(sheet, change) + def session_added_row(sheet, change, to) moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') participant = SessionAssignmentRoleType.find_by(name: 'Participant') # If it is an add and we have the reify before the time and room get the latest version of the object - object = change[:item_type].constantize.find change[:item_id] + object = ChangeService.session_as_of(session_id: change[:item_id], to: to) return unless object.start_time && object.room_id sheet.append_row( diff --git a/app/services/change_service.rb b/app/services/change_service.rb index 12b406e29..b68af9f5d 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -30,6 +30,16 @@ def self.dropped_people(from:, to: nil) res.uniq end + def self.session_as_of(session_id:, to:) + session_version = Audit::SessionVersion.where("item_id = ? and created_at <= ?", session_id, to) + .order('created_at desc') + .first + return nil unless session_version + + session = session_version.reify + return session + end + def self.sessions_changed(from:, to: nil) get_changes(clazz: Audit::SessionVersion, type: Session, from: from, to: to) end From cde0b1d0f2a4814ab8114610d6dffae5495beb43 Mon Sep 17 00:00:00 2001 From: Leane Verhulst Date: Fri, 19 Aug 2022 09:28:02 -0500 Subject: [PATCH 29/45] Update streamed tag to use Environment filter --- app/serializers/conclar/session_serializer.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/serializers/conclar/session_serializer.rb b/app/serializers/conclar/session_serializer.rb index 4d7b4c418..295644063 100644 --- a/app/serializers/conclar/session_serializer.rb +++ b/app/serializers/conclar/session_serializer.rb @@ -89,7 +89,7 @@ class Conclar::SessionSerializer < ActiveModel::Serializer if object.streamed t = { value: "session_streamed", - category: "Note", + category: "Environment", label: "Streamed" } res << t From 0b21e9780b47648e20be337cc3728eac0df94873 Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Aug 2022 14:35:50 -0400 Subject: [PATCH 30/45] plan-733, plan-735 fixes for pub diffs getting old state of relationships --- .../reports/schedule_reports_controller.rb | 9 +- app/services/change_service.rb | 94 ++++++++++++++----- 2 files changed, 80 insertions(+), 23 deletions(-) diff --git a/app/controllers/reports/schedule_reports_controller.rb b/app/controllers/reports/schedule_reports_controller.rb index b04607ce7..f3cc67451 100644 --- a/app/controllers/reports/schedule_reports_controller.rb +++ b/app/controllers/reports/schedule_reports_controller.rb @@ -340,6 +340,9 @@ def session_added_row(sheet, change, to) object = ChangeService.session_as_of(session_id: change[:item_id], to: to) return unless object.start_time && object.room_id + # Get the assignments at the time of change + assignments = ChangeService.assignments_as_of(session_id: change[:item_id], to: to) + sheet.append_row( [ object.title, @@ -348,8 +351,10 @@ def session_added_row(sheet, change, to) object.areas.collect(&:name).join("; "), FastExcel.date_num(object.start_time, object.start_time.in_time_zone.utc_offset), object.room&.name, - object.participant_assignments.where("session_assignment_role_type_id = ?", moderator).collect{|a| a.person.published_name}.join("; "), - object.participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") + assignments[:moderators].collect{|a| a.person.published_name}.join("; "), + assignments[:participants].collect{|a| a.person.published_name}.join("; ") + # object.participant_assignments.where("session_assignment_role_type_id = ?", moderator).collect{|a| a.person.published_name}.join("; "), + # object.participant_assignments.where("session_assignment_role_type_id = ?", participant).collect{|a| a.person.published_name}.join("; ") ], [ nil, nil, nil, nil, @date_time_style, nil, nil, nil diff --git a/app/services/change_service.rb b/app/services/change_service.rb index b68af9f5d..ddf8bc78d 100644 --- a/app/services/change_service.rb +++ b/app/services/change_service.rb @@ -31,13 +31,56 @@ def self.dropped_people(from:, to: nil) end def self.session_as_of(session_id:, to:) - session_version = Audit::SessionVersion.where("item_id = ? and created_at <= ?", session_id, to) + self.object_as_of(audit: Audit::SessionVersion, item_id: session_id, item_type: 'Session', to: to) + end + + def self.object_as_of(audit:, item_id:, item_type:, to:) + object_version = audit.where("item_id = ? and item_type = ? and created_at <= ?", item_id, item_type, to) .order('created_at desc') .first - return nil unless session_version + return nil unless object_version + + object = object_version.reify + return object + end - session = session_version.reify - return session + def self.assignments_as_of(session_id:, to:) + moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') + participant = SessionAssignmentRoleType.find_by(name: 'Participant') + + participants = self.assignments_for(session_id: session_id, role_id: participant.id, to: to) + moderators = self.assignments_for(session_id: session_id, role_id: moderator.id, to: to) + + { + participants: participants, + moderators: moderators + } + end + + def self.assignments_for(session_id:, role_id:, to:) + audits = Audit::SessionVersion + .where_object(session_id: session_id) + .where("created_at <= ?", to) + .order("created_at desc") + grouped_audits = audits.group_by {|a| a.item_id} + + res = [] + grouped_audits.each do |key, item_audits| + change = self.comnbined_changes(item_audits: item_audits, type: SessionAssignment) + res.concat [change[:object]] if self.assigned?(change: change, role_id: role_id) + end + + res + end + + def self.assigned?(change:, role_id:) + return false unless change[:object] + + return true if !change[:changes]['session_assignment_role_type_id'] && change[:object].session_assignment_role_type_id == role_id + + return true if change[:changes]['session_assignment_role_type_id'] && change[:changes]['session_assignment_role_type_id'][1] == role_id + + return false end def self.sessions_changed(from:, to: nil) @@ -76,23 +119,32 @@ def self.get_changes(clazz:, type:, from:, to:, publishable_session_ids: nil) grouped_audits.each do |key, item_audits| # Rails.logger.debug "**** AUDIT #{key} #{publishable_session_ids}" # just in case we sort by date - item_audits.sort{|a,b| a.created_at <=> b.created_at}.each do |audit| - # merge the change history - if changes[key] - changes[key][:changes] = self.merge_change_set(to: changes[key][:changes], from: audit.object_changes) - else - # Get the old version of the object - obj = if audit.event == 'create' - type.find(audit.item_id) if type.exists?(audit.item_id) - else - audit.reify - end - # obj = audit.reify - if publishable_session_ids - next unless publishable_session_ids.include?(obj.session_id) - end - changes[key] = {item_id: audit.item_id, item_type: audit.item_type, event: audit.event, object: obj, changes: audit.object_changes} - end + change = self.comnbined_changes(item_audits: item_audits, type: type) + if publishable_session_ids && change[:object].respond_to?(:session_id) + next unless publishable_session_ids.include?(change[:object].session_id) + end + + changes[key] = change + end + + changes + end + + def self.comnbined_changes(item_audits:, type:) + changes = nil + + item_audits.sort{|a,b| a.created_at <=> b.created_at}.each do |audit| + # merge the change history + if changes + changes[:changes] = self.merge_change_set(to: changes[:changes], from: audit.object_changes) + else + # Get the old version of the object + obj = if audit.event == 'create' + type.find(audit.item_id) if type.exists?(audit.item_id) + else + audit.reify + end + changes = {item_id: audit.item_id, item_type: audit.item_type, event: audit.event, object: obj, changes: audit.object_changes} end end From 477a7ef896c71cbf248cfff99286995b405fc9ed Mon Sep 17 00:00:00 2001 From: Henry Date: Fri, 19 Aug 2022 15:04:28 -0400 Subject: [PATCH 31/45] plan-721 virtual people report --- .../reports/program_ops_reports_controller.rb | 45 +++++++++++++++++++ app/javascript/reports/reports_screen.vue | 3 ++ .../reports/program_ops_report_policy.rb | 4 ++ config/routes.rb | 1 + lib/tasks/rbac.rake | 6 ++- 5 files changed, 57 insertions(+), 2 deletions(-) diff --git a/app/controllers/reports/program_ops_reports_controller.rb b/app/controllers/reports/program_ops_reports_controller.rb index 628123236..803fc1c26 100644 --- a/app/controllers/reports/program_ops_reports_controller.rb +++ b/app/controllers/reports/program_ops_reports_controller.rb @@ -1,6 +1,51 @@ class Reports::ProgramOpsReportsController < ApplicationController around_action :set_timezone + def virtual_people + authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy + + moderator = SessionAssignmentRoleType.find_by(name: 'Moderator') + participant = SessionAssignmentRoleType.find_by(name: 'Participant') + + assignments = PublishedSessionAssignment + .includes(:person, :session_assignment_role_type, :published_session) + .where("published_sessions.environment = 'virtual'") + .where("session_assignment_role_type_id in (?)", [moderator.id, participant.id]) + .order("people.published_name") + + workbook = FastExcel.open(constant_memory: true) + worksheet = workbook.add_worksheet("Virtual Participants") + + worksheet.append_row( + [ + 'Published Name', + 'Name', + 'Primary Email' + ] + ) + + group_assignments = assignments.group_by {|a| a.person} + group_assignments.each do |person, grouped| + row = [ + person.published_name, + person.name, + person.primary_email.email + ] + + person.email_addresses.each do |addr| + next if addr == person.primary_email + + row.concat [addr.email] + end + + worksheet.append_row(row) + end + + send_data workbook.read_string, + filename: "VirtualParticipants-#{Time.now.strftime('%m-%d-%Y')}.xlsx", + disposition: 'attachment' + end + def back_of_badge authorize SessionAssignment, policy_class: Reports::ProgramOpsReportPolicy diff --git a/app/javascript/reports/reports_screen.vue b/app/javascript/reports/reports_screen.vue index 3a2242688..b6d2087de 100644 --- a/app/javascript/reports/reports_screen.vue +++ b/app/javascript/reports/reports_screen.vue @@ -314,6 +314,9 @@ Session data included: all scheduled sessions that are visible and published

+
  • + Virtaul Program Participants +
  • diff --git a/app/policies/reports/program_ops_report_policy.rb b/app/policies/reports/program_ops_report_policy.rb index d573b7655..79b305b17 100644 --- a/app/policies/reports/program_ops_report_policy.rb +++ b/app/policies/reports/program_ops_report_policy.rb @@ -2,4 +2,8 @@ class Reports::ProgramOpsReportPolicy < BasePolicy def back_of_badge? allowed?(action: :back_of_badge) end + + def virtual_people? + allowed?(action: :virtual_people) + end end diff --git a/config/routes.rb b/config/routes.rb index a9ec66af6..a0f818daf 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -90,6 +90,7 @@ get 'report/people_reports/moderators', to: 'reports/people_reports#moderators' get 'report/program_ops_reports/back_of_badge', to: 'reports/program_ops_reports#back_of_badge' + get 'report/program_ops_reports/virtual_people', to: 'reports/program_ops_reports#virtual_people' get 'report/schedule_reports/schedule_diff(/:from)(/:to)', to: 'reports/schedule_reports#schedule_diff' get 'publication_date/reset', to: 'publication_dates#reset' diff --git a/lib/tasks/rbac.rake b/lib/tasks/rbac.rake index cd0a0811e..8763a1d43 100644 --- a/lib/tasks/rbac.rake +++ b/lib/tasks/rbac.rake @@ -548,7 +548,8 @@ namespace :rbac do "schedule_diff": true }, "program_ops_report": { - "back_of_badge": true + "back_of_badge": true, + "virtual_people": true }, "conflict_report": { "people_outside_availability": true, @@ -866,7 +867,8 @@ namespace :rbac do "schedule_diff": true }, "program_ops_report": { - "back_of_badge": true + "back_of_badge": true, + "virtual_people": true }, "session_conflict": { "conflicts_with": true, From d0f751fa527e344feb34deba609227a53196c703 Mon Sep 17 00:00:00 2001 From: dcterman <105614148+dcterman@users.noreply.github.com> Date: Fri, 19 Aug 2022 16:21:27 -0400 Subject: [PATCH 32/45] Add description lines to PLAN-721 report Also change name to Participant Emails for Virtual Sessions --- app/javascript/reports/reports_screen.vue | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/javascript/reports/reports_screen.vue b/app/javascript/reports/reports_screen.vue index b6d2087de..308007dd2 100644 --- a/app/javascript/reports/reports_screen.vue +++ b/app/javascript/reports/reports_screen.vue @@ -315,7 +315,13 @@

  • - Virtaul Program Participants + Participant Emails for Virtual Sessions +

    + Description: List of emails for participants attending at least one virtual session, one line per participant
    + Fields: Published name, name, primary email, other emails
    + Session data included: all published sessions + Person data included: moderators and participants assigned to at least one published session that has an environment of "virtual" +

  • From aad61e6cfc8ad7fb4bafc7fb976b20846e8dfee1 Mon Sep 17 00:00:00 2001 From: dcterman <105614148+dcterman@users.noreply.github.com> Date: Sat, 20 Aug 2022 15:03:14 -0400 Subject: [PATCH 33/45] Shorten abbrev for minutes to save output space --- app/controllers/reports/program_ops_reports_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/reports/program_ops_reports_controller.rb b/app/controllers/reports/program_ops_reports_controller.rb index 803fc1c26..1c9224364 100644 --- a/app/controllers/reports/program_ops_reports_controller.rb +++ b/app/controllers/reports/program_ops_reports_controller.rb @@ -72,7 +72,7 @@ def back_of_badge row.concat [ assignment.session.title, assignment.session.start_time ? FastExcel.date_num(assignment.session.start_time, assignment.session.start_time.in_time_zone.utc_offset) : nil, - "#{assignment.session.duration} mins", + "#{assignment.session.duration}m", assignment.session.room&.name, ] styles.concat [ From b1b97e91e4d4a0efd0c9b02cd446520ca37e098d Mon Sep 17 00:00:00 2001 From: dcterman <105614148+dcterman@users.noreply.github.com> Date: Sat, 20 Aug 2022 15:10:03 -0400 Subject: [PATCH 34/45] Change people flyout for stream & record & photo People flyout was showing Yes for livesteam allowed, recording allowed, and photographing allowed, regardless of the actual stored values (which can be seen on the people editor). --- app/javascript/people/detail.vue | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/javascript/people/detail.vue b/app/javascript/people/detail.vue index 4b7c0f68e..42bf0f651 100644 --- a/app/javascript/people/detail.vue +++ b/app/javascript/people/detail.vue @@ -31,11 +31,11 @@
    Can Share:
    {{ selected.can_share ? 'Y' : 'N' }}
    Can Photo:
    -
    {{ selected.can_photo ? 'Y' : 'N' }}
    +
    {{ selected.can_photo === "yes" ? 'Y' : 'N' }}
    Can Stream:
    -
    {{ selected.can_stream ? 'Y' : 'N' }}
    +
    {{ selected.can_stream === "yes" ? 'Y' : 'N' }}
    Can Record:
    -
    {{ selected.can_stream ? 'Y' : 'N' }}
    +
    {{ selected.can_record === "yes" ? 'Y' : 'N' }}
    From 06d49f0e57bf1e36f521b0e4b875fdabbec0f290 Mon Sep 17 00:00:00 2001 From: dcterman <105614148+dcterman@users.noreply.github.com> Date: Sat, 20 Aug 2022 15:31:31 -0400 Subject: [PATCH 35/45] Modify description for virtual report Correct the wording describing the report and fix missing line break. --- app/javascript/reports/reports_screen.vue | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/javascript/reports/reports_screen.vue b/app/javascript/reports/reports_screen.vue index 308007dd2..ba99ee414 100644 --- a/app/javascript/reports/reports_screen.vue +++ b/app/javascript/reports/reports_screen.vue @@ -315,12 +315,12 @@

  • - Participant Emails for Virtual Sessions + Participant Emails and Virtual Sessions

    - Description: List of emails for participants attending at least one virtual session, one line per participant
    - Fields: Published name, name, primary email, other emails
    - Session data included: all published sessions - Person data included: moderators and participants assigned to at least one published session that has an environment of "virtual" + Description: List of emails for moderators and participants of published sessions, with indicator about whether they are assigned to any session(s) of environment virtual, one line per participant
    + Fields: Published name, name, whether person is assigned to a virtual session (y∕n), primary email, other emails
    + Session data included: all published sessions
    + Person data included: moderators and participants

  • From 66f7397bcd4a802fba6c6b3186707697be7b77a5 Mon Sep 17 00:00:00 2001 From: Henry Date: Sat, 20 Aug 2022 16:42:16 -0400 Subject: [PATCH 36/45] change to include all participants on pub sessions and add is virtual col --- app/controllers/reports/program_ops_reports_controller.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/controllers/reports/program_ops_reports_controller.rb b/app/controllers/reports/program_ops_reports_controller.rb index 803fc1c26..801fa3b56 100644 --- a/app/controllers/reports/program_ops_reports_controller.rb +++ b/app/controllers/reports/program_ops_reports_controller.rb @@ -9,7 +9,6 @@ def virtual_people assignments = PublishedSessionAssignment .includes(:person, :session_assignment_role_type, :published_session) - .where("published_sessions.environment = 'virtual'") .where("session_assignment_role_type_id in (?)", [moderator.id, participant.id]) .order("people.published_name") @@ -20,6 +19,7 @@ def virtual_people [ 'Published Name', 'Name', + 'Is Virtual', 'Primary Email' ] ) @@ -29,6 +29,7 @@ def virtual_people row = [ person.published_name, person.name, + grouped.reduce(false){|res, a| res || (a.published_session.environment == 'virtual')} ? 'Yes' : 'No', # grouped contains virtual person.primary_email.email ] From 70f40c2b22fc76176a0a55df15a1fc9535c42833 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sun, 17 Jul 2022 22:16:04 -0400 Subject: [PATCH 37/45] PLAN-543 integrate with airmeet very basic so far - can turn a person into a speaker, and get info for the airmeet, and configure the airmeet. --- Gemfile | 3 + Gemfile.lock | 8 ++ app/controllers/integrations_controller.rb | 5 + app/helpers/integrations_helper.rb | 2 + app/models/integration.rb | 2 + app/policies/integration_policy.rb | 11 ++ app/services/airmeet_api_service.rb | 120 ++++++++++++++++++ .../20220717212351_create_integrations.rb | 16 +++ db/structure.sql | 85 ++++++++++++- lib/tasks/chicon_airmeet.rake | 39 ++++++ lib/tasks/rbac.rake | 9 ++ spec/helpers/integrations_helper_spec.rb | 15 +++ spec/models/integration_spec.rb | 5 + spec/requests/integrations_spec.rb | 7 + 14 files changed, 323 insertions(+), 4 deletions(-) create mode 100644 app/controllers/integrations_controller.rb create mode 100644 app/helpers/integrations_helper.rb create mode 100644 app/models/integration.rb create mode 100644 app/policies/integration_policy.rb create mode 100644 app/services/airmeet_api_service.rb create mode 100644 db/migrate/20220717212351_create_integrations.rb create mode 100644 lib/tasks/chicon_airmeet.rake create mode 100644 spec/helpers/integrations_helper_spec.rb create mode 100644 spec/models/integration_spec.rb create mode 100644 spec/requests/integrations_spec.rb diff --git a/Gemfile b/Gemfile index 060ea8618..c48006f28 100644 --- a/Gemfile +++ b/Gemfile @@ -64,6 +64,9 @@ gem 'truemail' # This is needed to run the migrations from id to uuid for primary keys gem 'webdack-uuid_migration' +# for integrations! +gem "httparty" + group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] diff --git a/Gemfile.lock b/Gemfile.lock index 78255a94c..131209798 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -153,6 +153,9 @@ GEM guard-compat (~> 1.0) multi_json (~> 1.8) http_parser.rb (0.8.0) + httparty (0.20.0) + mime-types (~> 3.0) + multi_xml (>= 0.5.2) i18n (1.12.0) concurrent-ruby (~> 1.0) io-wait (0.2.3) @@ -190,11 +193,15 @@ GEM marcel (1.0.2) matrix (0.4.2) method_source (1.0.0) + mime-types (3.4.1) + mime-types-data (~> 3.2015) + mime-types-data (3.2022.0105) mini_mime (1.1.2) mini_portile2 (2.8.0) minitest (5.16.3) msgpack (1.5.4) multi_json (1.15.0) + multi_xml (0.6.0) nenv (0.3.0) nilify_blanks (1.4.0) activerecord (>= 4.0.0) @@ -426,6 +433,7 @@ DEPENDENCIES fast_excel guard guard-livereload + httparty io-wait jbuilder (~> 2.7) jsonapi-serializer diff --git a/app/controllers/integrations_controller.rb b/app/controllers/integrations_controller.rb new file mode 100644 index 000000000..ce4266600 --- /dev/null +++ b/app/controllers/integrations_controller.rb @@ -0,0 +1,5 @@ +class IntegrationsController < ResourceController + # no view endpoints right now so no serializer needed + # SERIALIZER_CLASS = 'IntegrationSerializer'.freeze + POLICY_CLASS = 'IntegrationPolicy'.freeze +end diff --git a/app/helpers/integrations_helper.rb b/app/helpers/integrations_helper.rb new file mode 100644 index 000000000..e6b84107a --- /dev/null +++ b/app/helpers/integrations_helper.rb @@ -0,0 +1,2 @@ +module IntegrationsHelper +end diff --git a/app/models/integration.rb b/app/models/integration.rb new file mode 100644 index 000000000..66c9978d0 --- /dev/null +++ b/app/models/integration.rb @@ -0,0 +1,2 @@ +class Integration < ApplicationRecord +end diff --git a/app/policies/integration_policy.rb b/app/policies/integration_policy.rb new file mode 100644 index 000000000..ba99b63b2 --- /dev/null +++ b/app/policies/integration_policy.rb @@ -0,0 +1,11 @@ +class IntegrationPolicy < PlannerPolicy + def publish? + allowed?(action: :publish) + end + + class Scope < PlannerPolicy::Scope + def resolve + scope.all + end + end +end diff --git a/app/services/airmeet_api_service.rb b/app/services/airmeet_api_service.rb new file mode 100644 index 000000000..bd37103bc --- /dev/null +++ b/app/services/airmeet_api_service.rb @@ -0,0 +1,120 @@ +module AirmeetApiService + def self.integration + @integration ||= Integration.find_or_create_by({name: :airmeet}) + end + + def self.config + integration.config + end + + def self.token + if !config['token'] || Time.at(config['token_exp']) < Time.now + auth + else + config['token'] + end + end + + def self.airmeet_id + config['airmeet_id'] + end + + def self.airmeet + @airmeet ||= Airmeet.new + end + + def self.get_participants + Airmeet.get("/airmeet/#{airmeet_id}/participants") + end + + def self.auth + token = airmeet.auth["token"] + integration.update({config: config.merge({ + token: token, + token_exp: (Time.now + (29 * 24 * 60 * 60)).to_i + })}) + token + end + + def self.info + Airmeet.get("/airmeet/#{airmeet_id}/info") + end + + def self.get_session(id) + info["sessions"].find { |s| s["sessionid"] == id } + end + + def self.create_session(sessionTitle:, sessionStartTime:, sessionDuration:, sessionSummary:, hostEmail:, speakerEmails:, cohostEmails:) + sessionStartTime = sessionStartTime.to_i * 1000 + Airmeet.post("/airmeet/#{airmeet_id}/session", { + body: { + sessionTitle: sessionTitle, + sessionStartTime: sessionStartTime, + sessionDuration: sessionDuration, + sessionSummary: sessionSummary, + hostEmail: hostEmail, + speakerEmails: speakerEmails, + cohostEmails: cohostEmails, + type: "HOSTING" + } + }) + end + + def self.create_speaker(name:, email:, organisation: "", designation: "", imageUrl: "", bio: "", city: "", country: "") + Airmeet.post("/airmeet/#{airmeet_id}/speaker", { + body: { + name: name, + email: email, + organisation: organisation, + designation: designation, + imageUrl: imageUrl, + bio: bio, + city: city, + country: country, + }.to_json + }) + end + + def self.person_to_airmeet(person) + if person.integrations["airmeet"] + return person.integrations["airmeet"]["speaker_email"] + else + result = create_speaker({name: person.published_name, email: person.primary_email.email, bio: person.bio}) + puts result + person.update({integrations: person.integrations.merge({airmeet: {speaker_email: result["email"]}})}) + result["email"] + end + end + + def self.session_to_airmeet(session) + # TODO this is where i left off + if session.integrations["airmeet"] + end + end + + class Airmeet + include HTTParty + base_uri "https://api-gateway.airmeet.com/prod" + + headers 'Content-Type' => 'application/json' + + # TODO fix me for not testing + default_options.update(verify: false) + + def auth + self.class.post("/auth", { + headers: { + "X-Airmeet-Access-Key": ENV["AIRMEET_ACCESS_KEY"], + "X-Airmeet-Secret-Key": ENV["AIRMEET_SECRET_KEY"], + "X-Airmeet-Access-Token": "" + }, + verify: false + }) + end + + headers 'X-Airmeet-Access-Token' => AirmeetApiService.token + + + end + +end diff --git a/db/migrate/20220717212351_create_integrations.rb b/db/migrate/20220717212351_create_integrations.rb new file mode 100644 index 000000000..9fb8cc8fc --- /dev/null +++ b/db/migrate/20220717212351_create_integrations.rb @@ -0,0 +1,16 @@ +class CreateIntegrations < ActiveRecord::Migration[6.1] + def change + create_table :integrations, id: :uuid do |t| + t.string :name + t.jsonb :config, null: false, default: {} + + t.timestamps + end + + # fields to hold the integration information for each session/person/session_assignment/room + add_column :sessions, :integrations, :jsonb, null: false, default: {} + add_column :people, :integrations, :jsonb, null: false, default: {} + add_column :session_assignments, :integrations, :jsonb, null: false, default: {} + add_column :rooms, :integrations, :jsonb, null: false, default: {} + end +end diff --git a/db/structure.sql b/db/structure.sql index 34656c4e2..7adfb4f05 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -616,7 +616,8 @@ END) STORED, attendance_type character varying(200) DEFAULT NULL::character varying, twelve_hour boolean DEFAULT true, timezone character varying(500) DEFAULT NULL::character varying, - availability_notes character varying + availability_notes character varying, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -655,7 +656,8 @@ CREATE TABLE public.session_assignments ( interest_notes text, state character varying, planner_notes text, - interest_role public.interest_role_enum DEFAULT 'no_preference'::public.interest_role_enum + interest_role public.interest_role_enum DEFAULT 'no_preference'::public.interest_role_enum, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -699,7 +701,8 @@ CREATE TABLE public.sessions ( room_set_id uuid, room_notes text, recorded boolean DEFAULT false NOT NULL, - streamed boolean DEFAULT false NOT NULL + streamed boolean DEFAULT false NOT NULL, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -926,6 +929,19 @@ CREATE TABLE public.ignored_conflicts ( ); +-- +-- Name: integrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.integrations ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + name character varying, + config jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + -- -- Name: label_dimensions; Type: TABLE; Schema: public; Owner: - -- @@ -1289,6 +1305,25 @@ CREATE TABLE public.person_schedule_approvals ( ); +-- +-- Name: person_schedule_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.person_schedule_approvals_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: person_schedule_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.person_schedule_approvals_id_seq OWNED BY public.person_schedule_approvals.id; + + -- -- Name: person_schedule_conflicts; Type: VIEW; Schema: public; Owner: - -- @@ -1451,7 +1486,8 @@ CREATE TABLE public.rooms ( room_set_id uuid, length numeric, width numeric, - height numeric + height numeric, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -1567,6 +1603,25 @@ CREATE TABLE public.schedule_workflows ( ); +-- +-- Name: schedule_workflows_id_seq; Type: SEQUENCE; Schema: public; Owner: - +-- + +CREATE SEQUENCE public.schedule_workflows_id_seq + START WITH 1 + INCREMENT BY 1 + NO MINVALUE + NO MAXVALUE + CACHE 1; + + +-- +-- Name: schedule_workflows_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - +-- + +ALTER SEQUENCE public.schedule_workflows_id_seq OWNED BY public.schedule_workflows.id; + + -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- @@ -2044,6 +2099,20 @@ ALTER TABLE ONLY public.audit_survey_versions ALTER COLUMN id SET DEFAULT nextva ALTER TABLE ONLY public.categorizations ALTER COLUMN id SET DEFAULT nextval('public.categorizations_id_seq'::regclass); +-- +-- Name: person_schedule_approvals id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.person_schedule_approvals ALTER COLUMN id SET DEFAULT nextval('public.person_schedule_approvals_id_seq'::regclass); + + +-- +-- Name: schedule_workflows id; Type: DEFAULT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.schedule_workflows ALTER COLUMN id SET DEFAULT nextval('public.schedule_workflows_id_seq'::regclass); + + -- -- Name: survey_formats id; Type: DEFAULT; Schema: public; Owner: - -- @@ -2210,6 +2279,14 @@ ALTER TABLE ONLY public.ignored_conflicts ADD CONSTRAINT ignored_conflicts_pkey PRIMARY KEY (id); +-- +-- Name: integrations integrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.integrations + ADD CONSTRAINT integrations_pkey PRIMARY KEY (id); + + -- -- Name: label_dimensions label_dimensions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- diff --git a/lib/tasks/chicon_airmeet.rake b/lib/tasks/chicon_airmeet.rake new file mode 100644 index 000000000..c37428a0e --- /dev/null +++ b/lib/tasks/chicon_airmeet.rake @@ -0,0 +1,39 @@ +namespace :chicon do + desc "Configure airmeet for chicon" + task configure_airmeet_test: :environment do + integration = Integration.find_or_create_by({name: :airmeet}) + # this data is for testing. we are going to need the real information for the actual show here at some point. + # and/or create a ui for it but let's try this first. + # none of this gets you actual access to the airmeet so it's probably ok to actually check in??? + integration.update!({ + config: { + airmeet_id: "c8b39650-f33d-11ec-9c8a-2b58688a7745", + airmeet_host: "gail.terman@chicon.org", + active: true + } + }) + + Room.find_by({name: "Airmeet 1"}).update({integrations: {airmeet: {room_host_email: 'gail.terman@chicon.org'}}}) + end + + task configure_airmeet: :environment do + integration = Integration.find_or_create_by({name: :airmeet}) + # this data is for testing. we are going to need the real information for the actual show here at some point. + # and/or create a ui for it but let's try this first. + # none of this gets you actual access to the airmeet so it's probably ok to actually check in??? + integration.update!({ + config: { + airmeet_id: "NOT SET YET", + airmeet_host: "NOT SET YET", + active: false + } + }) + end + + task test_airmeet: :environment do + puts AirmeetApiService.info + puts AirmeetApiService.get_session("f1dc078f-f4dc-4a98-973a-8c364036256b") + puts AirmeetApiService.get_participants + end +end + diff --git a/lib/tasks/rbac.rake b/lib/tasks/rbac.rake index 8763a1d43..4ca88238c 100644 --- a/lib/tasks/rbac.rake +++ b/lib/tasks/rbac.rake @@ -281,6 +281,9 @@ namespace :rbac do }, "publication_date": { "index": false + }, + "integration": { + "publish": false } }) end @@ -590,6 +593,9 @@ namespace :rbac do }, "publication_date": { "index": true + }, + "integration": { + "publish": false } }) end @@ -899,6 +905,9 @@ namespace :rbac do }, "publication_date": { "index": true + }, + "integration": { + "publish": true } }) end diff --git a/spec/helpers/integrations_helper_spec.rb b/spec/helpers/integrations_helper_spec.rb new file mode 100644 index 000000000..c39979c7b --- /dev/null +++ b/spec/helpers/integrations_helper_spec.rb @@ -0,0 +1,15 @@ +require 'rails_helper' + +# Specs in this file have access to a helper object that includes +# the IntegrationsHelper. For example: +# +# describe IntegrationsHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +RSpec.describe IntegrationsHelper, type: :helper do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/models/integration_spec.rb b/spec/models/integration_spec.rb new file mode 100644 index 000000000..aae8d31da --- /dev/null +++ b/spec/models/integration_spec.rb @@ -0,0 +1,5 @@ +require 'rails_helper' + +RSpec.describe Integration, type: :model do + pending "add some examples to (or delete) #{__FILE__}" +end diff --git a/spec/requests/integrations_spec.rb b/spec/requests/integrations_spec.rb new file mode 100644 index 000000000..5426a96db --- /dev/null +++ b/spec/requests/integrations_spec.rb @@ -0,0 +1,7 @@ +require 'rails_helper' + +RSpec.describe "Integrations", type: :request do + describe "GET /index" do + pending "add some examples (or delete) #{__FILE__}" + end +end From 6df5f9ed15c35fbcae9d8cca398e7db0e5af22b1 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sun, 31 Jul 2022 12:29:21 -0400 Subject: [PATCH 38/45] more airmeet --- app/services/airmeet_api_service.rb | 19 ++++--- db/integrations.md | 57 +++++++++++++++++++ ... => 20220730212351_create_integrations.rb} | 0 3 files changed, 69 insertions(+), 7 deletions(-) create mode 100644 db/integrations.md rename db/migrate/{20220717212351_create_integrations.rb => 20220730212351_create_integrations.rb} (100%) diff --git a/app/services/airmeet_api_service.rb b/app/services/airmeet_api_service.rb index bd37103bc..b245db970 100644 --- a/app/services/airmeet_api_service.rb +++ b/app/services/airmeet_api_service.rb @@ -76,14 +76,19 @@ def self.create_speaker(name:, email:, organisation: "", designation: "", imageU end def self.person_to_airmeet(person) - if person.integrations["airmeet"] - return person.integrations["airmeet"]["speaker_email"] - else - result = create_speaker({name: person.published_name, email: person.primary_email.email, bio: person.bio}) - puts result - person.update({integrations: person.integrations.merge({airmeet: {speaker_email: result["email"]}})}) - result["email"] + speaker_email = person.primary_email.email + if person.integrations["airmeet"] + speaker_email = person.integrations["airmeet"]["speaker_email"] + if person.integrations["airmeet"]["synced"] + return speaker_email + end end + name = person.published_name + bio = person.bio + result = create_speaker({name: name, email: speaker_email, bio: bio}) + puts result + person.update({integrations: person.integrations.merge({airmeet: {speaker_email: result["email"], synced: true, name: name, bio: bio, synced_at: Time.now.iso8601}})}) + result["email"] end def self.session_to_airmeet(session) diff --git a/db/integrations.md b/db/integrations.md new file mode 100644 index 000000000..5df98effa --- /dev/null +++ b/db/integrations.md @@ -0,0 +1,57 @@ +This page should document what data structrue is expected for the integration columns + +## Config + + { + "airmeet_id": "uuid", + "airmeet_host": "host email", + "active": true, + "token": "jwt set by the system here" + "token_exp": "time set by the system here" + } + +## Session + + { + "airmeet": { + "synced": true + "synced_at": "ISO8601 timestamp", + "sessionTitle": "generated string here" , + "sesionStartTime": "epoch in ms", + "sessionDuration": "number in minutes", + "sessionSummary": "generated string here" + "hostEmail": "room email", + "speakerEmails": "speaker emails", + "cohostEmails": "moderator emails", + "sessionId": "??" + } + } + +## Person + + { + "airmeet": { + "synced": true + "speaker_email": "speaker@email.com" + "bio": "bio here", + "name": "name here" + "synced_at": "ISO8601 timestamp" + } + } + +## Session Assignment + + { + "airmeet": { + "magic_link": "here" + "synced_at": "ISO8601 timestamp" + } + } + +## Room + + { + "airmeet": { + "room_host_email": "helpdesk+roomname@chicon.org" + } + } diff --git a/db/migrate/20220717212351_create_integrations.rb b/db/migrate/20220730212351_create_integrations.rb similarity index 100% rename from db/migrate/20220717212351_create_integrations.rb rename to db/migrate/20220730212351_create_integrations.rb From 3f9042e4150e9dc9538e9baeb7d78b2ea405bf31 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sun, 7 Aug 2022 18:25:59 -0400 Subject: [PATCH 39/45] very minor additional airmeet progress --- Gemfile | 1 + Gemfile.lock | 2 + .../administration/admin_component.vue | 7 +- app/javascript/airmeet/airmeet_settings.vue | 68 +++++++++++++++++++ .../20220730212351_create_integrations.rb | 16 ----- .../20220807123400_create_integrations.rb | 27 ++++++++ db/structure.sql | 44 +----------- 7 files changed, 107 insertions(+), 58 deletions(-) create mode 100644 app/javascript/airmeet/airmeet_settings.vue delete mode 100644 db/migrate/20220730212351_create_integrations.rb create mode 100644 db/migrate/20220807123400_create_integrations.rb diff --git a/Gemfile b/Gemfile index c48006f28..53330492a 100644 --- a/Gemfile +++ b/Gemfile @@ -66,6 +66,7 @@ gem 'webdack-uuid_migration' # for integrations! gem "httparty" +gem "json-diff" group :development, :test do # Call 'byebug' anywhere in the code to stop execution and get a debugger console diff --git a/Gemfile.lock b/Gemfile.lock index 131209798..12f0cbf71 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -163,6 +163,7 @@ GEM actionview (>= 5.0.0) activesupport (>= 5.0.0) json (2.6.2) + json-diff (0.4.1) jsonapi-renderer (0.2.2) jsonapi-serializer (2.2.0) activesupport (>= 4.2) @@ -436,6 +437,7 @@ DEPENDENCIES httparty io-wait jbuilder (~> 2.7) + json-diff jsonapi-serializer jsonapi.rb kaminari diff --git a/app/javascript/administration/admin_component.vue b/app/javascript/administration/admin_component.vue index ca2206691..cacf3e6d2 100644 --- a/app/javascript/administration/admin_component.vue +++ b/app/javascript/administration/admin_component.vue @@ -56,6 +56,9 @@ ref="agreements-manager" > + + + @@ -69,6 +72,7 @@ import ConfigurationsManager from '../configurations/configurations_manager'; import SheetImporterVue from '../components/sheet_importer_vue.vue'; import AgreementManager from "@/agreements/agreement_manager"; import ScheduleSettings from "@/schedule/schedule_settings.vue"; +import AirmeetSettings from "@/airmeet/airmeet_settings.vue"; export default { components: { @@ -79,7 +83,8 @@ export default { SheetImporterVue, MailingsManager, ConfigurationsManager, - ScheduleSettings + ScheduleSettings, + AirmeetSettings }, name: 'AdminComponent', data: () => ({ diff --git a/app/javascript/airmeet/airmeet_settings.vue b/app/javascript/airmeet/airmeet_settings.vue new file mode 100644 index 000000000..889800270 --- /dev/null +++ b/app/javascript/airmeet/airmeet_settings.vue @@ -0,0 +1,68 @@ + + + + + diff --git a/db/migrate/20220730212351_create_integrations.rb b/db/migrate/20220730212351_create_integrations.rb deleted file mode 100644 index 9fb8cc8fc..000000000 --- a/db/migrate/20220730212351_create_integrations.rb +++ /dev/null @@ -1,16 +0,0 @@ -class CreateIntegrations < ActiveRecord::Migration[6.1] - def change - create_table :integrations, id: :uuid do |t| - t.string :name - t.jsonb :config, null: false, default: {} - - t.timestamps - end - - # fields to hold the integration information for each session/person/session_assignment/room - add_column :sessions, :integrations, :jsonb, null: false, default: {} - add_column :people, :integrations, :jsonb, null: false, default: {} - add_column :session_assignments, :integrations, :jsonb, null: false, default: {} - add_column :rooms, :integrations, :jsonb, null: false, default: {} - end -end diff --git a/db/migrate/20220807123400_create_integrations.rb b/db/migrate/20220807123400_create_integrations.rb new file mode 100644 index 000000000..0f9e91fc2 --- /dev/null +++ b/db/migrate/20220807123400_create_integrations.rb @@ -0,0 +1,27 @@ +class CreateIntegrations < ActiveRecord::Migration[6.1] + def change + create_table :integrations, id: :uuid do |t| + t.string :name + t.jsonb :config, null: false, default: {} + + t.timestamps + end + + create_table :integration_publishes, id: :uuid do |t| + t.string :integration_name + t.jsonb :data, null: false, default: {} + t.datetime :started_at + t.datetime :completed_at + t.string :created_by + + t.timestamps + end + + # fields to hold the integration information for each session/person/session_assignment/room + add_column :published_sessions, :integrations, :jsonb, null: false, default: {} + add_column :people, :integrations, :jsonb, null: false, default: {} + # todo maybe i don't need this one if the tokens are always the same + add_column :published_session_assignments, :integrations, :jsonb, null: false, default: {} + add_column :rooms, :integrations, :jsonb, null: false, default: {} + end +end diff --git a/db/structure.sql b/db/structure.sql index 7adfb4f05..b73c97a59 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -616,8 +616,7 @@ END) STORED, attendance_type character varying(200) DEFAULT NULL::character varying, twelve_hour boolean DEFAULT true, timezone character varying(500) DEFAULT NULL::character varying, - availability_notes character varying, - integrations jsonb DEFAULT '{}'::jsonb NOT NULL + availability_notes character varying ); @@ -656,8 +655,7 @@ CREATE TABLE public.session_assignments ( interest_notes text, state character varying, planner_notes text, - interest_role public.interest_role_enum DEFAULT 'no_preference'::public.interest_role_enum, - integrations jsonb DEFAULT '{}'::jsonb NOT NULL + interest_role public.interest_role_enum DEFAULT 'no_preference'::public.interest_role_enum ); @@ -929,19 +927,6 @@ CREATE TABLE public.ignored_conflicts ( ); --- --- Name: integrations; Type: TABLE; Schema: public; Owner: - --- - -CREATE TABLE public.integrations ( - id uuid DEFAULT public.gen_random_uuid() NOT NULL, - name character varying, - config jsonb DEFAULT '{}'::jsonb NOT NULL, - created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL -); - - -- -- Name: label_dimensions; Type: TABLE; Schema: public; Owner: - -- @@ -1486,8 +1471,7 @@ CREATE TABLE public.rooms ( room_set_id uuid, length numeric, width numeric, - height numeric, - integrations jsonb DEFAULT '{}'::jsonb NOT NULL + height numeric ); @@ -2099,20 +2083,6 @@ ALTER TABLE ONLY public.audit_survey_versions ALTER COLUMN id SET DEFAULT nextva ALTER TABLE ONLY public.categorizations ALTER COLUMN id SET DEFAULT nextval('public.categorizations_id_seq'::regclass); --- --- Name: person_schedule_approvals id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.person_schedule_approvals ALTER COLUMN id SET DEFAULT nextval('public.person_schedule_approvals_id_seq'::regclass); - - --- --- Name: schedule_workflows id; Type: DEFAULT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.schedule_workflows ALTER COLUMN id SET DEFAULT nextval('public.schedule_workflows_id_seq'::regclass); - - -- -- Name: survey_formats id; Type: DEFAULT; Schema: public; Owner: - -- @@ -2279,14 +2249,6 @@ ALTER TABLE ONLY public.ignored_conflicts ADD CONSTRAINT ignored_conflicts_pkey PRIMARY KEY (id); --- --- Name: integrations integrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - --- - -ALTER TABLE ONLY public.integrations - ADD CONSTRAINT integrations_pkey PRIMARY KEY (id); - - -- -- Name: label_dimensions label_dimensions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- From ed39285c3c19a835ca9f8b761f2673718a68ca98 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Wed, 17 Aug 2022 08:41:08 -0400 Subject: [PATCH 40/45] re-date migration --- ...eate_integrations.rb => 20220816183400_create_integrations.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename db/migrate/{20220807123400_create_integrations.rb => 20220816183400_create_integrations.rb} (100%) diff --git a/db/migrate/20220807123400_create_integrations.rb b/db/migrate/20220816183400_create_integrations.rb similarity index 100% rename from db/migrate/20220807123400_create_integrations.rb rename to db/migrate/20220816183400_create_integrations.rb From 1979322d977420ec4a161778602854d40e10d084 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Wed, 17 Aug 2022 09:38:15 -0400 Subject: [PATCH 41/45] more work on settings tab --- .../administration/admin_component.vue | 14 ++++---- app/javascript/airmeet/airmeet_settings.vue | 34 +++++++++++-------- .../integrations/integration_settings.vue | 28 +++++++++++++++ app/serializers/room_serializer.rb | 2 +- 4 files changed, 56 insertions(+), 22 deletions(-) create mode 100644 app/javascript/integrations/integration_settings.vue diff --git a/app/javascript/administration/admin_component.vue b/app/javascript/administration/admin_component.vue index cacf3e6d2..9a3cebdef 100644 --- a/app/javascript/administration/admin_component.vue +++ b/app/javascript/administration/admin_component.vue @@ -57,7 +57,7 @@ > - + @@ -66,13 +66,13 @@ + + diff --git a/app/serializers/room_serializer.rb b/app/serializers/room_serializer.rb index a675c0b05..772c3ee93 100644 --- a/app/serializers/room_serializer.rb +++ b/app/serializers/room_serializer.rb @@ -5,7 +5,7 @@ class RoomSerializer :name, :sort_order, :purpose, :comment, :capacity, :floor, :open_for_schedule, :is_virtual, :area_of_space, :length, :width, :height, - :venue_id, :room_set_id + :venue_id, :room_set_id, :integrations end From ba59b74f0f916a3fb348dbc31f5c013e6a8b0a63 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Thu, 18 Aug 2022 20:58:59 -0400 Subject: [PATCH 42/45] add create_session_from_session or whatever --- app/services/airmeet_api_service.rb | 12 +++- ... => 20220818200500_create_integrations.rb} | 0 db/structure.sql | 61 +++++++++++++++++-- 3 files changed, 65 insertions(+), 8 deletions(-) rename db/migrate/{20220816183400_create_integrations.rb => 20220818200500_create_integrations.rb} (100%) diff --git a/app/services/airmeet_api_service.rb b/app/services/airmeet_api_service.rb index b245db970..fcceb41df 100644 --- a/app/services/airmeet_api_service.rb +++ b/app/services/airmeet_api_service.rb @@ -92,9 +92,15 @@ def self.person_to_airmeet(person) end def self.session_to_airmeet(session) - # TODO this is where i left off - if session.integrations["airmeet"] - end + args = {sessionTitle: "#{session.room.name} - #{session.title} - #{session.format.name} - #{session.area_list.join(", ")}", + sessionSummary: session.description, + sessionDuration: session.duration, + sessionStartTime: session.start_time, + hostEmail: session.room.integrations["airmeet"]["room_host_email"], + speakerEmails: session.session_assignments.map { |sa| sa.person.integrations.airmeet.speaker_email}, + cohostEmails: session.session_assignments.filter { |sa| sa.session_assignment_role_type_id == moderator_id }.map { |sa| sa.person.integrations.airmeet.speaker_email }} + result = create_session(args); + session.update({integrations: session.integrations.merge({airmeet: {session_id: result.id, synced: true, synced_at: Time.now()}})}) end class Airmeet diff --git a/db/migrate/20220816183400_create_integrations.rb b/db/migrate/20220818200500_create_integrations.rb similarity index 100% rename from db/migrate/20220816183400_create_integrations.rb rename to db/migrate/20220818200500_create_integrations.rb diff --git a/db/structure.sql b/db/structure.sql index b73c97a59..ed858d1ea 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -616,7 +616,8 @@ END) STORED, attendance_type character varying(200) DEFAULT NULL::character varying, twelve_hour boolean DEFAULT true, timezone character varying(500) DEFAULT NULL::character varying, - availability_notes character varying + availability_notes character varying, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -927,6 +928,35 @@ CREATE TABLE public.ignored_conflicts ( ); +-- +-- Name: integration_publishes; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.integration_publishes ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + integration_name character varying, + data jsonb DEFAULT '{}'::jsonb NOT NULL, + started_at timestamp without time zone, + completed_at timestamp without time zone, + created_by character varying, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + +-- +-- Name: integrations; Type: TABLE; Schema: public; Owner: - +-- + +CREATE TABLE public.integrations ( + id uuid DEFAULT public.gen_random_uuid() NOT NULL, + name character varying, + config jsonb DEFAULT '{}'::jsonb NOT NULL, + created_at timestamp(6) without time zone NOT NULL, + updated_at timestamp(6) without time zone NOT NULL +); + + -- -- Name: label_dimensions; Type: TABLE; Schema: public; Owner: - -- @@ -1416,7 +1446,8 @@ CREATE TABLE public.published_session_assignments ( session_assignment_role_type_id uuid NOT NULL, person_id uuid NOT NULL, sort_order integer, - visibility public.visibility_enum DEFAULT 'public'::public.visibility_enum + visibility public.visibility_enum DEFAULT 'public'::public.visibility_enum, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -1445,7 +1476,8 @@ CREATE TABLE public.published_sessions ( environment public.session_environments_enum DEFAULT 'unknown'::public.session_environments_enum, minors_participation jsonb, recorded boolean DEFAULT false NOT NULL, - streamed boolean DEFAULT false NOT NULL + streamed boolean DEFAULT false NOT NULL, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -1471,7 +1503,8 @@ CREATE TABLE public.rooms ( room_set_id uuid, length numeric, width numeric, - height numeric + height numeric, + integrations jsonb DEFAULT '{}'::jsonb NOT NULL ); @@ -2249,6 +2282,22 @@ ALTER TABLE ONLY public.ignored_conflicts ADD CONSTRAINT ignored_conflicts_pkey PRIMARY KEY (id); +-- +-- Name: integration_publishes integration_publishes_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.integration_publishes + ADD CONSTRAINT integration_publishes_pkey PRIMARY KEY (id); + + +-- +-- Name: integrations integrations_pkey; Type: CONSTRAINT; Schema: public; Owner: - +-- + +ALTER TABLE ONLY public.integrations + ADD CONSTRAINT integrations_pkey PRIMARY KEY (id); + + -- -- Name: label_dimensions label_dimensions_pkey; Type: CONSTRAINT; Schema: public; Owner: - -- @@ -3412,6 +3461,8 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220726130346'), ('20220801152151'), ('20220801173704'), -('20220801195644'); +('20220801195644'), +('20220818022629'), +('20220818200500'); From 5f6caf845994ddc31d009db97f2757481dbdd160 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sat, 20 Aug 2022 22:17:33 -0400 Subject: [PATCH 43/45] AIRMEET WORKS --- app/controllers/integrations_controller.rb | 31 ++++++- .../published_sessions_controller.rb | 4 +- .../administration/admin_component.vue | 6 +- app/javascript/airmeet/airmeet_settings.vue | 62 ++++++++++---- app/javascript/people/person_tabs.vue | 6 ++ app/javascript/sessions/session_tabs.vue | 21 ++++- app/javascript/store/integration.store.js | 28 +++++++ app/javascript/store/model.store.js | 12 ++- .../store/published_session.store.js | 11 +++ app/policies/integration_policy.rb | 8 ++ app/policies/published_session_policy.rb | 7 ++ app/serializers/integration_serializer.rb | 15 ++++ app/serializers/person_serializer.rb | 3 +- .../published_session_serializer.rb | 2 +- app/services/airmeet_api_service.rb | 81 ++++++++++++++----- config/routes.rb | 4 +- ...001724_add_lock_version_to_integrations.rb | 5 ++ db/structure.sql | 6 +- lib/tasks/chicon_airmeet.rake | 10 +-- 19 files changed, 268 insertions(+), 54 deletions(-) create mode 100644 app/javascript/store/integration.store.js create mode 100644 app/javascript/store/published_session.store.js create mode 100644 app/policies/published_session_policy.rb create mode 100644 app/serializers/integration_serializer.rb create mode 100644 db/migrate/20220821001724_add_lock_version_to_integrations.rb diff --git a/app/controllers/integrations_controller.rb b/app/controllers/integrations_controller.rb index ce4266600..a08633870 100644 --- a/app/controllers/integrations_controller.rb +++ b/app/controllers/integrations_controller.rb @@ -1,5 +1,32 @@ class IntegrationsController < ResourceController - # no view endpoints right now so no serializer needed - # SERIALIZER_CLASS = 'IntegrationSerializer'.freeze + SERIALIZER_CLASS = 'IntegrationSerializer'.freeze POLICY_CLASS = 'IntegrationPolicy'.freeze + + def airmeet + authorize model_class, policy_class: policy_class + + airmeet = Integration.find_by({name: 'airmeet'}) + + render json: serializer_class.new(airmeet, + { + include: serializer_includes, + params: {domain: "#{request.base_url}"} + } + ).serializable_hash(), + content_type: 'application/json' + end + + def allowed_params + %i[ + id + name + lock_version + ] << [ + config: %i[ + airmeet_host + airmeet_id + ] + ] + end + end diff --git a/app/controllers/published_sessions_controller.rb b/app/controllers/published_sessions_controller.rb index e0bf0d590..615a3c781 100644 --- a/app/controllers/published_sessions_controller.rb +++ b/app/controllers/published_sessions_controller.rb @@ -1,3 +1,5 @@ class PublishedSessionsController < ResourceController -# TBD + SERIALIZER_CLASS = 'PublishedSessionSerializer'.freeze + POLICY_CLASS = 'PublishedSessionPolicy'.freeze +# end diff --git a/app/javascript/administration/admin_component.vue b/app/javascript/administration/admin_component.vue index 9a3cebdef..d628ac732 100644 --- a/app/javascript/administration/admin_component.vue +++ b/app/javascript/administration/admin_component.vue @@ -50,15 +50,15 @@ ref="configurations-manager" > + + + - - - diff --git a/app/javascript/airmeet/airmeet_settings.vue b/app/javascript/airmeet/airmeet_settings.vue index 1edfbaf6a..298d98670 100644 --- a/app/javascript/airmeet/airmeet_settings.vue +++ b/app/javascript/airmeet/airmeet_settings.vue @@ -2,24 +2,26 @@
    -

    Configuration

    +

    Configuration

    - + - + -

    Rooms

    - - - - +

    Room Hosts Setup

    + Add Airmeet Room +
    + + + +
    @@ -27,21 +29,23 @@ diff --git a/app/javascript/people/person_tabs.vue b/app/javascript/people/person_tabs.vue index 90ac4467b..c902d47e5 100644 --- a/app/javascript/people/person_tabs.vue +++ b/app/javascript/people/person_tabs.vue @@ -53,6 +53,9 @@ + +
    {{JSON.stringify(person.integrations, undefined, 2)}}
    +
    @@ -132,6 +135,9 @@ export default { baseTabs.push('email'); baseTabs.push('admin'); } + if(this.currentUserIsAdmin) { + baseTabs.push('integrations'); + } return baseTabs; }, person() { diff --git a/app/javascript/sessions/session_tabs.vue b/app/javascript/sessions/session_tabs.vue index 5b7c53d27..f1928dc5d 100644 --- a/app/javascript/sessions/session_tabs.vue +++ b/app/javascript/sessions/session_tabs.vue @@ -30,6 +30,9 @@ + +
    {{JSON.stringify(published_session.integrations, undefined, 2)}}
    +
    @@ -48,6 +51,8 @@ import SessionSchedule from './session_schedule'; import SessionConflicts from '../conflicts/session_conflicts.vue' import { sessionConflictModel } from '@/store/session_conflict.store' import settingsMixin from "@/store/settings.mixin"; +import { personSessionMixin } from '@/mixins'; +import { publishedSessionModel } from '@/store/published_session.store'; export default { name: "SessionTabs", @@ -65,16 +70,20 @@ export default { }, mixins: [ modelUtilsMixin, - settingsMixin + settingsMixin, + personSessionMixin ], data: () => ({ sessionAssignmentModel, - sessionConflictModel + sessionConflictModel, }), computed: { session() { return this.selected_model(sessionModel); }, + published_session() { + return this.selected_model(publishedSessionModel) || {}; + }, assignmentFilter() { let filter = { "op": "all", @@ -120,6 +129,9 @@ export default { case 4: path = `notes/${this.id}`; break; + case 5: + path = `integrations/${this.id}` + break; } // console.debug("****** Path:", path) // change the router path to match the current tab @@ -138,7 +150,10 @@ export default { (obj) => { this.select_model(sessionModel, obj); } - ) + ), + this.fetch_model_by_id(publishedSessionModel, this.id).then( (obj) => { + this.select_model(publishedSessionModel, obj) + }) } } diff --git a/app/javascript/store/integration.store.js b/app/javascript/store/integration.store.js new file mode 100644 index 000000000..c00767a21 --- /dev/null +++ b/app/javascript/store/integration.store.js @@ -0,0 +1,28 @@ +import { FETCH } from "./model.store" + +export const integrationModel = 'integration' + +export const integrationEndpoints = { + [integrationModel]: 'integration' +} + +export const FETCH_AIRMEET_INTEGRATION = 'FETCH AIRMEET INTEGRATION' +export const SET_AIRMEET_INTEGRATION = 'SET AIRMEET INTEGRATION' + +export const integrationStore = { + state: { + airmeet: {} + }, + mutations: { + [SET_AIRMEET_INTEGRATION] (state, integration) { + state.airmeet = integration; + } + }, + actions: { + [FETCH_AIRMEET_INTEGRATION] ({dispatch, commit}) { + dispatch(FETCH, {url: 'integration/airmeet'}).then(data => { + commit(SET_AIRMEET_INTEGRATION, data); + }) + } + } +} diff --git a/app/javascript/store/model.store.js b/app/javascript/store/model.store.js index 677963979..962632d35 100644 --- a/app/javascript/store/model.store.js +++ b/app/javascript/store/model.store.js @@ -75,9 +75,11 @@ import { configurationStore, configurationEndpoints } from './configuration.stor // session add-ons import { sessionAssignmentStore, sessionAssignmentEndpoints } from './session_assignment.store'; +import { publishedSessionEndpoints, publishedSessionStore } from './published_session.store'; // global app things import { appStore } from './app.store'; +import { integrationEndpoints, integrationStore } from './integration.store'; // schedule workflow import { scheduleWorkflowStore, scheduleWorkflowEndpoints } from './schedule_workflow/schedule_workflow.store'; @@ -106,6 +108,9 @@ const endpoints = { // ...personExclusionEndpoints, ...scheduleWorkflowEndpoints, ...personScheduleApprovalEndpoints, + ...publicationDatesEndpoints, + ...publishedSessionEndpoints, + ...integrationEndpoints, } // NOTE: this is really the store @@ -142,6 +147,8 @@ export const store = new Vuex.Store({ ...sessionConflictStore.selected, ...formatStore.selected, ...personScheduleApprovalStore.selected, + ...publicationDatesStore.selected, + ...publishedSessionStore.selected, }, ...personSessionStore.state, ...settingsStore.state, @@ -153,6 +160,7 @@ export const store = new Vuex.Store({ ...roomStore.state, ...appStore.state, ...scheduleWorkflowStore.state, + ...integrationStore.state, // ...mailingStore.state }, getters: { @@ -211,7 +219,8 @@ export const store = new Vuex.Store({ ...surveyStore.mutations, ...searchStateStore.mutations, ...roomStore.mutations, - ...appStore.mutations + ...appStore.mutations, + ...integrationStore.mutations }, actions: { /** @@ -381,5 +390,6 @@ export const store = new Vuex.Store({ ...sessionConflictStore.actions, ...scheduleWorkflowStore.actions, ...personScheduleApprovalStore.actions, + ...integrationStore.actions, } }) diff --git a/app/javascript/store/published_session.store.js b/app/javascript/store/published_session.store.js new file mode 100644 index 000000000..2acf4d994 --- /dev/null +++ b/app/javascript/store/published_session.store.js @@ -0,0 +1,11 @@ +export const publishedSessionModel = 'published_session' + +export const publishedSessionEndpoints = { + [publishedSessionModel]: 'published_session' +} + +export const publishedSessionStore = { + selected: { + [publishedSessionModel]: null + } +} diff --git a/app/policies/integration_policy.rb b/app/policies/integration_policy.rb index ba99b63b2..85e09549d 100644 --- a/app/policies/integration_policy.rb +++ b/app/policies/integration_policy.rb @@ -3,6 +3,14 @@ def publish? allowed?(action: :publish) end + def airmeet? + allowed?(action: :airmeet) + end + + def update? + allowed?(action: :update) + end + class Scope < PlannerPolicy::Scope def resolve scope.all diff --git a/app/policies/published_session_policy.rb b/app/policies/published_session_policy.rb new file mode 100644 index 000000000..16736953f --- /dev/null +++ b/app/policies/published_session_policy.rb @@ -0,0 +1,7 @@ +class PublishedSessionPolicy < PlannerPolicy + class Scope < PlannerPolicy::Scope + def resolve + scope.all + end + end +end diff --git a/app/serializers/integration_serializer.rb b/app/serializers/integration_serializer.rb new file mode 100644 index 000000000..0120b3c9b --- /dev/null +++ b/app/serializers/integration_serializer.rb @@ -0,0 +1,15 @@ +class IntegrationSerializer + include JSONAPI::Serializer + + attributes :lock_version, :created_at, :updated_at, + :name, :id + + attribute :config do |integration| + {airmeet_id: integration.config["airmeet_id"], + airmeet_host: integration.config["airmeet_host"] + } + end + + + +end diff --git a/app/serializers/person_serializer.rb b/app/serializers/person_serializer.rb index f58785557..f757ac4c5 100644 --- a/app/serializers/person_serializer.rb +++ b/app/serializers/person_serializer.rb @@ -41,7 +41,8 @@ class PersonSerializer #< ActiveModel::Serializer :timezone, :twelve_hour, :attendance_type, - :availability_notes + :availability_notes, + :integrations # status and comments hidden except for staff protected_attributes :con_state, :comments diff --git a/app/serializers/published_session_serializer.rb b/app/serializers/published_session_serializer.rb index e7bffc08a..4150e7cb1 100644 --- a/app/serializers/published_session_serializer.rb +++ b/app/serializers/published_session_serializer.rb @@ -1,5 +1,5 @@ class PublishedSessionSerializer include JSONAPI::Serializer - attributes :id, :lock_version, :created_at, :updated_at + attributes :id, :lock_version, :created_at, :updated_at, :integrations end diff --git a/app/services/airmeet_api_service.rb b/app/services/airmeet_api_service.rb index fcceb41df..7bbb58b4c 100644 --- a/app/services/airmeet_api_service.rb +++ b/app/services/airmeet_api_service.rb @@ -44,7 +44,7 @@ def self.get_session(id) info["sessions"].find { |s| s["sessionid"] == id } end - def self.create_session(sessionTitle:, sessionStartTime:, sessionDuration:, sessionSummary:, hostEmail:, speakerEmails:, cohostEmails:) + def self.create_session(sessionTitle:, sessionStartTime:, sessionDuration:, sessionSummary:, hostEmail:, speakerEmails: [], cohostEmails: []) sessionStartTime = sessionStartTime.to_i * 1000 Airmeet.post("/airmeet/#{airmeet_id}/session", { body: { @@ -56,7 +56,7 @@ def self.create_session(sessionTitle:, sessionStartTime:, sessionDuration:, sess speakerEmails: speakerEmails, cohostEmails: cohostEmails, type: "HOSTING" - } + }.to_json }) end @@ -68,7 +68,7 @@ def self.create_speaker(name:, email:, organisation: "", designation: "", imageU organisation: organisation, designation: designation, imageUrl: imageUrl, - bio: bio, + bio: bio || " ", city: city, country: country, }.to_json @@ -77,30 +77,77 @@ def self.create_speaker(name:, email:, organisation: "", designation: "", imageU def self.person_to_airmeet(person) speaker_email = person.primary_email.email + country = nil + city = nil if person.integrations["airmeet"] - speaker_email = person.integrations["airmeet"]["speaker_email"] - if person.integrations["airmeet"]["synced"] - return speaker_email - end + speaker_email = person.integrations["airmeet"]["speaker_email"] || speaker_email + country = person.integrations["airmeet"]["country"] + city = person.integrations["airmeet"]["city"] end name = person.published_name bio = person.bio - result = create_speaker({name: name, email: speaker_email, bio: bio}) + args = {name: name, email: speaker_email, bio: bio} + if country + args[:country] = country + end + if city + args[:city] = city + end + puts args + result = create_speaker(args) puts result - person.update({integrations: person.integrations.merge({airmeet: {speaker_email: result["email"], synced: true, name: name, bio: bio, synced_at: Time.now.iso8601}})}) + person.update({integrations: person.integrations.merge({airmeet: {speaker_email: speaker_email, synced: true, data: args, synced_at: Time.now.iso8601}})}) result["email"] end def self.session_to_airmeet(session) args = {sessionTitle: "#{session.room.name} - #{session.title} - #{session.format.name} - #{session.area_list.join(", ")}", - sessionSummary: session.description, - sessionDuration: session.duration, - sessionStartTime: session.start_time, - hostEmail: session.room.integrations["airmeet"]["room_host_email"], - speakerEmails: session.session_assignments.map { |sa| sa.person.integrations.airmeet.speaker_email}, - cohostEmails: session.session_assignments.filter { |sa| sa.session_assignment_role_type_id == moderator_id }.map { |sa| sa.person.integrations.airmeet.speaker_email }} + sessionSummary: session.description, + sessionDuration: session.duration, + sessionStartTime: session.start_time, + hostEmail: room_hosts[session.room_id] + }; + participants = session.published_session_assignments.filter { |sa| sa.session_assignment_role_type_id == moderator_id || sa.session_assignment_role_type_id == participant_id }.map { |sa| sa.person } + if session.environment == "virtual" + args[:speakerEmails] = participants.map{|p| p.integrations["airmeet"]["speaker_email"]} + args[:cohostEmails] = session.published_session_assignments.filter { |sa| sa.session_assignment_role_type_id == moderator_id }.map { |sa| sa.person.integrations["airmeet"]["speaker_email"] } + end + puts args result = create_session(args); - session.update({integrations: session.integrations.merge({airmeet: {session_id: result.id, synced: true, synced_at: Time.now()}})}) + puts result + session.update({integrations: session.integrations.merge({airmeet: {session_id: result["uid"], synced: true, synced_at: Time.now(), data: args}})}) + if session.environment == "virtual" + people_tokens = result["token"].inject({}) {|p,c| p[c["email"]] = c["token"]; p} + participants.each { |p| p.update({integrations: p.integrations.merge({airmeet: (p.integrations["airmeet"] || {}).merge({token: people_tokens[(p.integrations["airmeet"] || {})["speaker_email"]]})})})} + end + end + + def self.room_hosts + @room_hosts ||= Room.where.not(integrations: {}).inject({}) { |p, c| p[c.id] = (c.integrations["airmeet"] || {})["room_host_email"]; p } + end + + def self.virtual_people + Person.left_outer_joins(:published_session_assignments, :published_sessions, :primary_email) + .where(published_sessions: { environment: 'virtual' }, published_session_assignments: {session_assignment_role_type_id: [moderator_id, participant_id]}) + .distinct + end + + def self.virtual_sessions + SessionService.published_sessions_unordered.where(streamed: true) + end + + def self.moderator_id + @moderator_id = SessionAssignmentRoleType.find_by(name: 'Moderator').id + end + + def self.participant_id + @participant_id = SessionAssignmentRoleType.find_by(name: 'Participant').id + end + + def self.sync_to_airmeet + virtual_people.map { |p| person_to_airmeet(p) } + virtual_sessions.map { |s| session_to_airmeet(s) } + puts "AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA IT WORKED" end class Airmeet @@ -124,8 +171,6 @@ def auth end headers 'X-Airmeet-Access-Token' => AirmeetApiService.token - - end end diff --git a/config/routes.rb b/config/routes.rb index a0f818daf..c6d9f4522 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -94,7 +94,9 @@ get 'report/schedule_reports/schedule_diff(/:from)(/:to)', to: 'reports/schedule_reports#schedule_diff' get 'publication_date/reset', to: 'publication_dates#reset' - resources :publication_dates, path: 'publication_date', only: [:index] + resources :publication_dates, path: 'publication_date', only: [:index, :update] + resources :integrations, path: 'integration', only: [:index, :update] + get 'integration/airmeet', to: 'integrations#airmeet' resources :availabilities, path: 'availability', except: [:index] resources :person_exclusions, path: 'person_exclusion', except: [:index] diff --git a/db/migrate/20220821001724_add_lock_version_to_integrations.rb b/db/migrate/20220821001724_add_lock_version_to_integrations.rb new file mode 100644 index 000000000..842c72b2f --- /dev/null +++ b/db/migrate/20220821001724_add_lock_version_to_integrations.rb @@ -0,0 +1,5 @@ +class AddLockVersionToIntegrations < ActiveRecord::Migration[6.1] + def change + add_column :integrations, :lock_version, :integer, default: 0 + end +end diff --git a/db/structure.sql b/db/structure.sql index ed858d1ea..9f3b718c1 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -953,7 +953,8 @@ CREATE TABLE public.integrations ( name character varying, config jsonb DEFAULT '{}'::jsonb NOT NULL, created_at timestamp(6) without time zone NOT NULL, - updated_at timestamp(6) without time zone NOT NULL + updated_at timestamp(6) without time zone NOT NULL, + lock_version integer DEFAULT 0 ); @@ -3463,6 +3464,7 @@ INSERT INTO "schema_migrations" (version) VALUES ('20220801173704'), ('20220801195644'), ('20220818022629'), -('20220818200500'); +('20220818200500'), +('20220821001724'); diff --git a/lib/tasks/chicon_airmeet.rake b/lib/tasks/chicon_airmeet.rake index c37428a0e..a9d5de663 100644 --- a/lib/tasks/chicon_airmeet.rake +++ b/lib/tasks/chicon_airmeet.rake @@ -7,13 +7,13 @@ namespace :chicon do # none of this gets you actual access to the airmeet so it's probably ok to actually check in??? integration.update!({ config: { - airmeet_id: "c8b39650-f33d-11ec-9c8a-2b58688a7745", + airmeet_id: "ac4b0bc0-1079-11ed-bed5-3112cc3e0b52", airmeet_host: "gail.terman@chicon.org", active: true } }) - Room.find_by({name: "Airmeet 1"}).update({integrations: {airmeet: {room_host_email: 'gail.terman@chicon.org'}}}) + # Room.find_by({name: "Airmeet 1"}).update({integrations: {airmeet: {room_host_email: 'gail.terman@chicon.org'}}}) end task configure_airmeet: :environment do @@ -30,10 +30,8 @@ namespace :chicon do }) end - task test_airmeet: :environment do - puts AirmeetApiService.info - puts AirmeetApiService.get_session("f1dc078f-f4dc-4a98-973a-8c364036256b") - puts AirmeetApiService.get_participants + task sync_airmeet: :environment do + AirmeetApiService.sync_to_airmeet end end From a85a22094c6d7914e10de1bfb25d5085a7cc7430 Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sun, 21 Aug 2022 10:47:51 -0400 Subject: [PATCH 44/45] fix rebase errors --- app/controllers/integrations_controller.rb | 6 +-- app/javascript/store/model.store.js | 2 - app/services/airmeet_api_service.rb | 2 +- db/structure.sql | 45 ++-------------------- 4 files changed, 6 insertions(+), 49 deletions(-) diff --git a/app/controllers/integrations_controller.rb b/app/controllers/integrations_controller.rb index a08633870..8bcd1bc0c 100644 --- a/app/controllers/integrations_controller.rb +++ b/app/controllers/integrations_controller.rb @@ -21,11 +21,7 @@ def allowed_params id name lock_version - ] << [ - config: %i[ - airmeet_host - airmeet_id - ] + config ] end diff --git a/app/javascript/store/model.store.js b/app/javascript/store/model.store.js index 962632d35..3f7939da2 100644 --- a/app/javascript/store/model.store.js +++ b/app/javascript/store/model.store.js @@ -108,7 +108,6 @@ const endpoints = { // ...personExclusionEndpoints, ...scheduleWorkflowEndpoints, ...personScheduleApprovalEndpoints, - ...publicationDatesEndpoints, ...publishedSessionEndpoints, ...integrationEndpoints, } @@ -147,7 +146,6 @@ export const store = new Vuex.Store({ ...sessionConflictStore.selected, ...formatStore.selected, ...personScheduleApprovalStore.selected, - ...publicationDatesStore.selected, ...publishedSessionStore.selected, }, ...personSessionStore.state, diff --git a/app/services/airmeet_api_service.rb b/app/services/airmeet_api_service.rb index 7bbb58b4c..16ed3e1c8 100644 --- a/app/services/airmeet_api_service.rb +++ b/app/services/airmeet_api_service.rb @@ -133,7 +133,7 @@ def self.virtual_people end def self.virtual_sessions - SessionService.published_sessions_unordered.where(streamed: true) + SessionService.published_sessions.where(streamed: true) end def self.moderator_id diff --git a/db/structure.sql b/db/structure.sql index 9f3b718c1..4d3757d1c 100644 --- a/db/structure.sql +++ b/db/structure.sql @@ -700,8 +700,7 @@ CREATE TABLE public.sessions ( room_set_id uuid, room_notes text, recorded boolean DEFAULT false NOT NULL, - streamed boolean DEFAULT false NOT NULL, - integrations jsonb DEFAULT '{}'::jsonb NOT NULL + streamed boolean DEFAULT false NOT NULL ); @@ -1321,25 +1320,6 @@ CREATE TABLE public.person_schedule_approvals ( ); --- --- Name: person_schedule_approvals_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.person_schedule_approvals_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: person_schedule_approvals_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.person_schedule_approvals_id_seq OWNED BY public.person_schedule_approvals.id; - - -- -- Name: person_schedule_conflicts; Type: VIEW; Schema: public; Owner: - -- @@ -1402,7 +1382,9 @@ CREATE TABLE public.publication_dates ( dropped_sessions integer DEFAULT 0, new_assignments integer DEFAULT 0, updated_assignments integer DEFAULT 0, - dropped_assignments integer DEFAULT 0 + dropped_assignments integer DEFAULT 0, + sent_external boolean DEFAULT false NOT NULL, + lock_version integer DEFAULT 0 ); @@ -1621,25 +1603,6 @@ CREATE TABLE public.schedule_workflows ( ); --- --- Name: schedule_workflows_id_seq; Type: SEQUENCE; Schema: public; Owner: - --- - -CREATE SEQUENCE public.schedule_workflows_id_seq - START WITH 1 - INCREMENT BY 1 - NO MINVALUE - NO MAXVALUE - CACHE 1; - - --- --- Name: schedule_workflows_id_seq; Type: SEQUENCE OWNED BY; Schema: public; Owner: - --- - -ALTER SEQUENCE public.schedule_workflows_id_seq OWNED BY public.schedule_workflows.id; - - -- -- Name: schema_migrations; Type: TABLE; Schema: public; Owner: - -- From c5f4f64b3b57c9ec6accbc793389818f6113bb4b Mon Sep 17 00:00:00 2001 From: Gail Terman Date: Sun, 21 Aug 2022 10:54:14 -0400 Subject: [PATCH 45/45] fix airmeet settings save --- app/javascript/airmeet/airmeet_settings.vue | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/app/javascript/airmeet/airmeet_settings.vue b/app/javascript/airmeet/airmeet_settings.vue index 298d98670..d24dfba94 100644 --- a/app/javascript/airmeet/airmeet_settings.vue +++ b/app/javascript/airmeet/airmeet_settings.vue @@ -29,9 +29,9 @@