From 1649b3e6188e0ea066b06164106bb5342047a22b Mon Sep 17 00:00:00 2001 From: bohung Date: Sun, 22 May 2022 18:50:34 +0800 Subject: [PATCH] Fix bug. --- app/models/bulletin.rb | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/app/models/bulletin.rb b/app/models/bulletin.rb index 0f6b13d..10cfd13 100644 --- a/app/models/bulletin.rb +++ b/app/models/bulletin.rb @@ -405,17 +405,9 @@ class Bulletin a["bulletin_carousel_images"] = self.bulletin_carousel_images.map{|image| {"src"=>"#{base_url}" + image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }} a["external_link"] = self["is_external_link"] ? self.external_link : nil self.tags.each do |tag| - if !tag_ids.include?(tag.id.to_s) - tag_ids << tag.id.to_s - tag_names << {"name_translations" => tag.name_translations} - end a["tags"] << {"name_translations" => tag.name_translations} end cat = self.category - if (!category_ids.include?(cat.id.to_s) rescue false) - category_ids << cat.id.to_s - category_titles << {"title_translations" => cat.title_translations} - end a["category"] = {"title_translations" => (cat.title_translations rescue {})} self.bulletin_links.each do |bl| b = {} @@ -433,7 +425,9 @@ class Bulletin return a end def get_related_feeds - related_feeds = BulletinFeed.any_of({:category_ids=>self.category_id.to_s}, {:tag_ids.in=>self.tag_ids.map(&:to_s)}).to_a + @category_id ||= self.category_id + @tag_ids ||= self.tag_ids + related_feeds = BulletinFeed.any_of({:category_ids=>@category_id.to_s}, {:tag_ids.in=>@tag_ids.map(&:to_s)}).to_a end def notify_feed(type="create") related_feeds = self.get_related_feeds.select{|feed| feed.remote_urls.count != 0}