From 00e2a6e95e6deaa89bbda799b7b32cf2aa051644 Mon Sep 17 00:00:00 2001 From: BoHung Chiu Date: Mon, 6 Mar 2023 11:06:20 +0800 Subject: [PATCH] Fix bug. --- lib/bulletin_model/cache.rb | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/lib/bulletin_model/cache.rb b/lib/bulletin_model/cache.rb index b13bee3..89424b0 100644 --- a/lib/bulletin_model/cache.rb +++ b/lib/bulletin_model/cache.rb @@ -8,7 +8,7 @@ module BulletinModel before_destroy :cache_tag_ids end def cache_tag_ids - if self.class == Bulletin + if self.class == ::Bulletin @tag_ids = self.tag_ids @org_tag_ids = self.org_tag_ids @category_id = self.category_id @@ -16,19 +16,19 @@ module BulletinModel end end def do_before_save - if self.class == SubPart - AnnsCache.where(parent_id: /^#{self.id}/).delete - elsif self.class == Bulletin || (self.class == Page && self.module == "announcement") - if self.class == Bulletin + if self.class == ::SubPart + ::AnnsCache.where(parent_id: /^#{self.id}/).delete + elsif self.class == ::Bulletin || (self.class == ::Page && self.module == "announcement") + if self.class == ::Bulletin tmp_tag_ids = (Array(@tag_ids) + Array(@org_tag_ids)).uniq tmp_cat_ids = (Array(@category_id) + Array(@org_category_id)).uniq Thread.new do - BulletinFeedCache.where(:uid.in => BulletinFeed.any_of([{:tag_ids.in => tmp_tag_ids.collect{|v| v.to_s}},{:category_ids.in => tmp_cat_ids.collect{|v| v.to_s}}]).pluck(:uid)).to_a.each do |cache| + ::BulletinFeedCache.where(:uid.in => ::BulletinFeed.any_of([{:tag_ids.in => tmp_tag_ids.collect{|v| v.to_s}},{:category_ids.in => tmp_cat_ids.collect{|v| v.to_s}}]).pluck(:uid)).to_a.each do |cache| cache.regenerate end end end - AnnsCache.all.delete + ::AnnsCache.all.delete end end end