fix feed cache error

This commit is contained in:
chiu 2020-09-01 14:56:25 +08:00
parent aca4818b7b
commit 53c5d91035
2 changed files with 12 additions and 1 deletions

View File

@ -10,6 +10,17 @@ class Bulletin
include Slug
require 'bulletin_model/cache'
include BulletinModel::Cache
attr_accessor :org_tag_ids
def tags=(ids)
self.org_tag_ids = self.tag_ids
super(ids)
end
def []=(index,value)
if index.to_s=='tags'
self.org_tag_ids = self.tag_ids
end
super(index,value)
end
SubPart.class_eval { include BulletinModel::Cache }
Page.class_eval { include BulletinModel::Cache }
before_destroy do

View File

@ -10,7 +10,7 @@ module BulletinModel
AnnsCache.where(parent_id:self.id).destroy
elsif self.class == Bulletin || (self.class == Page && self.module == "announcement")
if self.class == Bulletin
tmp_tag_ids = (Array(self.tag_ids) + Array(Bulletin.find(self.id).tag_ids)).uniq
tmp_tag_ids = (Array(self.tag_ids) + Array(self.org_tag_ids)).uniq
BulletinFeedCache.where(:uid.in => BulletinFeed.where(:tag_ids.in => tmp_tag_ids.collect{|v| v.to_s}).pluck(:uid)).destroy
end
AnnsCache.all.destroy