diff --git a/app/models/snapshot.rb b/app/models/snapshot.rb index db5a4b958..29ae84e9c 100644 --- a/app/models/snapshot.rb +++ b/app/models/snapshot.rb @@ -30,7 +30,9 @@ class Snapshot < ApplicationRecord belongs_to :scorer, optional: true # shouldn't be optional! # see the call back delete_associated_objects for special delete logic. - has_many :snapshot_queries, dependent: :delete_all + # rubocop:disable Rails/HasManyOrHasOneDependent + has_many :snapshot_queries + # rubocop:enable Rails/HasManyOrHasOneDependent has_many :snapshot_docs, through: :snapshot_queries diff --git a/app/services/fetch_service.rb b/app/services/fetch_service.rb index b0d27f090..e61bf7e04 100644 --- a/app/services/fetch_service.rb +++ b/app/services/fetch_service.rb @@ -52,7 +52,8 @@ def complete # Keep the first snapshot, and the most recents, deleting the ones out of the middle. # Not the best sampling! snapshot_to_delete = @case.snapshots[1..((@options[:snapshot_limit] * -1) + @case.snapshots.count)] - snapshot_to_delete&.each(&:destroy) + # snapshot_to_delete&.each(&:destroy) + snapshot_to_delete.each(&:destroy!) end # rubocop:disable Metrics/MethodLength