Update app/models/work_side_pairing.rb

This commit is contained in:
agnes 2026-11-17 04:15:15 +00:00
parent 092154118b
commit b7f56fa0ba

View file

@ -4,4 +4,22 @@ belongs_to :relationship,
class_name: "Relationship" class_name: "Relationship"
validates :relationship_id, validates :relationship_id,
uniqueness: { scope: :work_id } uniqueness: { scope: :work_id }
after_create :update_filters
after_destroy :update_filters
after_create :update_relationship
after_destroy :update_relationship
def update_filters
return unless work && !work.destroyed?
work.update_filters
end end
def update_relationship
return unless relationship && !relationship.destroyed?
relationship.update_tag_cache
relationship.enqueue_to_index if relationship.taggings_count < ArchiveConfig.TAGGINGS_COUNT_REINDEX_LIMIT
end
end