otwarchive-side-pairings/app/models/work_side_pairing.rb

26 lines
641 B
Ruby
Raw Normal View History

2026-11-15 21:42:43 +00:00
class WorkSidePairing < ApplicationRecord
belongs_to :work
belongs_to :relationship,
class_name: "Relationship"
validates :relationship_id,
uniqueness: { scope: :work_id }
2026-11-17 04:15:15 +00:00
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
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