Merge pull request #7720 from artoscinote/ma_SCI_10890

Fix repository row touch for checklist values [SCI-10890]
This commit is contained in:
Martin Artnik 2024-07-17 10:54:42 +02:00 committed by GitHub
commit 69165c96a6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -6,14 +6,18 @@ class RepositoryChecklistItemsValue < ApplicationRecord
validates :repository_checklist_item, :repository_checklist_value, presence: true
after_create :touch_repository_checklist_value
before_destroy :touch_repository_checklist_value
after_commit :touch_repository_checklist_value
private
# rubocop:disable Rails/SkipsModelValidations
def touch_repository_checklist_value
repository_checklist_value.touch
# check if value was deleted, if so, touch repositroy_row directly
if RepositoryChecklistValue.exists?(repository_checklist_value.id)
repository_checklist_value.touch
elsif RepositoryRow.exists?(repository_checklist_value.repository_cell.repository_row.id)
repository_checklist_value.repository_cell.repository_row.touch
end
end
# rubocop:enable Rails/SkipsModelValidations
end