diff --git a/app/models/work_side_pairing.rb b/app/models/work_side_pairing.rb index 46a7659..52913ce 100644 --- a/app/models/work_side_pairing.rb +++ b/app/models/work_side_pairing.rb @@ -4,4 +4,22 @@ belongs_to :relationship, class_name: "Relationship" validates :relationship_id, uniqueness: { scope: :work_id } -end \ No newline at end of file + +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 +