Skip to content

Commit

Permalink
Merge pull request #418 from ChicagoWorldcon/staging
Browse files Browse the repository at this point in the history
1.5.0
  • Loading branch information
balen authored Jul 13, 2022
2 parents 17c5828 + 12a77db commit 1776edf
Show file tree
Hide file tree
Showing 72 changed files with 1,529 additions and 504 deletions.
3 changes: 2 additions & 1 deletion app/controllers/concerns/resource_methods.rb
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,8 @@ def update
after_update
end
end
after_update_tx
ret = after_update_tx
return if ret
render_object(@object)
end

Expand Down
2 changes: 2 additions & 0 deletions app/controllers/conflicts/session_conflicts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,9 @@ def conflicts_with
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("session_conflicts.conflict_id not in (select conflict_id from ignored_conflicts)")
.where("session_conflicts.conflict_type != 'room_conflict' OR (session_conflicts.conflict_type = 'room_conflict' AND session_conflicts.session_start_time != session_conflicts.conflict_session_start_time)")
.distinct
# .where("session_conflicts.conflict_type != 'person_schedule_conflict' and session_conflicts.conflict_type != 'person_back_to_back'")

meta = {}
meta[:total] = collection.count
Expand Down
35 changes: 35 additions & 0 deletions app/controllers/people_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,41 @@ def me
)
end

def draft_sessions
authorize current_person, policy_class: policy_class

person = Person.find params[:person_id]

if person
sessions = person.sessions
.eager_load({participant_assignments: :person}, :format, :session_areas)
.where("session_assignments.session_assignment_role_type_id is not null AND session_assignments.state != 'rejected'")
.where("session_assignments.session_assignment_role_type_id not in (select id from session_assignment_role_type where session_assignment_role_type.name = 'Reserve')")
.where("sessions.start_time is not null AND sessions.room_id is not null")
.order("sessions.start_time asc, sessions.title asc")

render json: SessionSerializer.new(
sessions,
{
# need assgnments and rooms etc
include: [
:format,
:room,
:session_areas,
:'session_areas.area',
:participant_assignments,
:'participant_assignments.person'
],
params: {
domain: "#{request.base_url}",
current_person: current_person
}
}
).serializable_hash(),
content_type: 'application/json'
end
end

# Get all the session names for the people ids passed in
def session_names
authorize current_person, policy_class: policy_class
Expand Down
147 changes: 123 additions & 24 deletions app/controllers/reports/conflict_reports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,6 +1,92 @@
class Reports::ConflictReportsController < ApplicationController
around_action :set_timezone

def all_ignored_conflicts
authorize SessionAssignment, policy_class: Reports::ConflictReportPolicy

conflicts = ReportsService::all_conflicts(ignored: true)

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("All Conflicts")

worksheet.append_row(
[
'Session',
'Areas',
'Start Time',
'Session Duration',
'Room',
'Person',
'Conflict Type'
]
)
date_time_style = workbook.number_format("d mmm yyyy h:mm")
styles = [
nil, nil, date_time_style, nil, nil
]
conflicts.each do |conflict|
worksheet.append_row(
[
conflict.session_title,
conflict.area_list.join('; '),
FastExcel.date_num(conflict.session_start_time, conflict.session_start_time.in_time_zone.utc_offset),
conflict.session&.duration,
conflict.room&.name,
conflict.person_published_name,
conflict.conflict_type,
],
styles
)
end

send_data workbook.read_string,
filename: "all_ignored_conflicts#{Time.now.strftime('%m-%d-%Y')}.xlsx",
disposition: 'attachment'
end

def all_conflicts
authorize SessionAssignment, policy_class: Reports::ConflictReportPolicy

conflicts = ReportsService::all_conflicts

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("All Conflicts")

worksheet.append_row(
[
'Session',
'Areas',
'Start Time',
'Session Duration',
'Room',
'Person',
'Conflict Type'
]
)
date_time_style = workbook.number_format("d mmm yyyy h:mm")
styles = [
nil, nil, date_time_style, nil, nil, nil, nil
]
conflicts.each do |conflict|
worksheet.append_row(
[
conflict.session_title,
conflict.area_list.join('; '),
FastExcel.date_num(conflict.session_start_time, conflict.session_start_time.in_time_zone.utc_offset),
conflict.session_duration,
conflict.room&.name,
conflict.person_published_name,
conflict.conflict_type
],
styles
)
end

send_data workbook.read_string,
filename: "all_conflicts#{Time.now.strftime('%m-%d-%Y')}.xlsx",
disposition: 'attachment'
end

def multiple_sessions_in_room
authorize SessionAssignment, policy_class: Reports::ConflictReportPolicy

Expand All @@ -9,6 +95,7 @@ def multiple_sessions_in_room
.includes(:room)
.references(:room)
.where("room_conflicts.back_to_back = false")
.where("room_conflicts.id not in (select conflict_id from ignored_conflicts)")
.order('rooms.name, start_time')

workbook = FastExcel.open(constant_memory: true)
Expand Down Expand Up @@ -69,6 +156,7 @@ def person_exclusion_conflicts
:person, :session, :exclusion, :excluded_session
)
.where("session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("person_exclusion_conflicts.id not in (select conflict_id from ignored_conflicts)")
.order('people.published_name asc')

workbook = FastExcel.open(constant_memory: true)
Expand Down Expand Up @@ -153,13 +241,14 @@ def back_to_back_to_back
'middle_areas_list.area_list as middle_area_list',
'conflict_areas_list.area_list as conflict_area_list'
)
.includes(:room, :middle_room, :conflict_room)
.references(:room, :middle_room, :conflict_room)
.joins(joins)
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("middle_session_assignment_name is null or middle_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.order('published_name asc, start_time asc')
.includes(:room, :middle_room, :conflict_room)
.references(:room, :middle_room, :conflict_room)
.joins(joins)
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("middle_session_assignment_name is null or middle_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("(b2b_id not in (select conflict_id from ignored_conflicts)) OR (conflict_b2b_id not in (select conflict_id from ignored_conflicts))")
.order('published_name asc, start_time asc')

#
workbook = FastExcel.open(constant_memory: true)
Expand Down Expand Up @@ -255,16 +344,17 @@ def back_to_back
]

conflicts = Conflicts::PersonBackToBack.select(
Conflicts::PersonBackToBack.arel_table[Arel.star],
'areas_list.area_list as area_list',
'conflict_areas_list.area_list as conflict_area_list'
)
.includes(:room, :conflict_room)
.references(:room, :conflict_room)
.joins(joins)
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.order('published_name asc, conflict_start_time asc')
Conflicts::PersonBackToBack.arel_table[Arel.star],
'areas_list.area_list as area_list',
'conflict_areas_list.area_list as conflict_area_list'
)
.includes(:room, :conflict_room)
.references(:room, :conflict_room)
.joins(joins)
.where("person_back_to_back.id not in (select conflict_id from ignored_conflicts)")
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.order('published_name asc, conflict_start_time asc')

workbook = FastExcel.open(constant_memory: true)
worksheet = workbook.add_worksheet("People Scheduled Back to Back")
Expand Down Expand Up @@ -346,6 +436,7 @@ def people_double_booked
)
.includes(:person, :session, :conflict_session, :room, :conflict_room)
.joins(joins)
.where("person_schedule_conflicts.id not in (select conflict_id from ignored_conflicts)")
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.where("conflict_session_assignment_name is null or conflict_session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.order('people.published_name asc, start_time asc')
Expand All @@ -357,6 +448,7 @@ def people_double_booked
[
'Name',
'Published Name',
'Participant Status',
'Time',
'Session',
'Area',
Expand All @@ -368,13 +460,14 @@ def people_double_booked
]
)
date_time_style = workbook.number_format("d mmm yyyy h:mm")
styles = [nil, nil, date_time_style, nil, nil, nil, nil, nil]
styles = [nil, nil, nil, date_time_style, nil, nil, nil, nil, nil]

conflicts.each do |conflict|
worksheet.append_row(
[
conflict.person.name,
conflict.person.published_name,
conflict.person.con_state,
FastExcel.date_num(conflict.session.start_time, conflict.session.start_time.in_time_zone.utc_offset),
conflict.session.title,
conflict.area_list.join('; '),
Expand Down Expand Up @@ -413,7 +506,9 @@ def people_outside_availability
'areas_list.area_list'
)
.includes(:session, :person)
.eager_load(person: :availabilities)
.joins(joins)
.where("availability_conflicts.id not in (select conflict_id from ignored_conflicts)")
.where("session_assignment_name is null or session_assignment_name in ('Moderator', 'Participant', 'Invisible')")
.order('people.published_name')

Expand All @@ -424,25 +519,29 @@ def people_outside_availability
worksheet.append_row(
[
'Name',
'Pub Name',
'Published Name',
'Participant Status',
'Session',
'Area',
'Start Time'

'Start Time',
'Session Duration',
'Availability'
]
)
date_time_style = workbook.number_format("d mmm yyyy h:mm")
styles = [nil, nil, nil, nil, date_time_style, nil]
styles = [nil, nil, nil, nil, nil, date_time_style, nil, nil]

conflicts.each do |conflict|
worksheet.append_row(
[
conflict.person.name,
conflict.person.published_name,
conflict.person.con_state,
conflict.session.title,
conflict.area_list.join('; '),
FastExcel.date_num(conflict.session.start_time, conflict.session.start_time.in_time_zone.utc_offset)

FastExcel.date_num(conflict.session.start_time, conflict.session.start_time.in_time_zone.utc_offset),
conflict.session.duration,
conflict.person.availabilities.order('start_time').collect{|av| "#{av.start_time} to #{av.end_time}" }.join(";\n"),
],
styles
)
Expand Down
Loading

0 comments on commit 1776edf

Please sign in to comment.