From 53c5d91035f375ec1c29f19eb5832476a98b749d Mon Sep 17 00:00:00 2001 From: chiu Date: Tue, 1 Sep 2020 14:56:25 +0800 Subject: [PATCH] fix feed cache error --- app/models/bulletin.rb | 11 +++++++++++ lib/bulletin_model/cache.rb | 2 +- 2 files changed, 12 insertions(+), 1 deletion(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index df1a510..8e36977 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -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 diff --git a/lib/bulletin_model/cache.rb b/lib/bulletin_model/cache.rb index 461fbf5..bd8a652 100644 --- a/lib/bulletin_model/cache.rb +++ b/lib/bulletin_model/cache.rb @@ -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