Skip to content

Commit

Permalink
Merge pull request #686 from ChicagoWorldcon/PLAN-744-fix-diffs
Browse files Browse the repository at this point in the history
PLAN-744 fix diffs for session state and sched change (2.0.2)
  • Loading branch information
Gailbear authored Aug 22, 2022
2 parents 8ef40bd + 548df80 commit 014f8be
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
2 changes: 1 addition & 1 deletion app/controllers/reports/schedule_reports_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ def session_room_change_row(sheet, change)
def session_removed_row(sheet, change)
sheet.append_row(
[
change[:recent].title
change[:object].title
]
)
end
Expand Down
8 changes: 5 additions & 3 deletions app/services/change_service.rb
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,12 @@ 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
object = if object_version
object_version.reify
# We want the object as it is after the change (hence next and reify)
object = if object_version.next
# need to apply the changes
object_version.next.reify
else
item_type.constantize.find(session_id) if item_type.constantize.exists?(id)
item_type.constantize.find(item_id) if item_type.constantize.exists?(item_id)
end

return object
Expand Down

0 comments on commit 014f8be

Please sign in to comment.