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
+