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,