Skip to content

Commit

Permalink
Merge pull request #652 from ChicagoWorldcon/stag-more-diff-fixes
Browse files Browse the repository at this point in the history
fix diff issue for current (2.0.1)
  • Loading branch information
Gailbear authored Aug 18, 2022
2 parents 9a7cf0b + b93c663 commit ead47d6
Showing 1 changed file with 15 additions and 9 deletions.
24 changes: 15 additions & 9 deletions app/controllers/reports/schedule_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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,
]
Expand Down Expand Up @@ -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(
[
Expand Down

0 comments on commit ead47d6

Please sign in to comment.