This commit is contained in:
BoHung Chiu 2022-05-22 18:50:34 +08:00
parent 842eac72f0
commit 1649b3e618
1 changed files with 3 additions and 9 deletions

View File

@ -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}