fix error

This commit is contained in:
邱博亞 2023-04-08 23:29:04 +08:00
parent 09b6b81f5a
commit b801cd64b7
1 changed files with 12 additions and 12 deletions

View File

@ -11,17 +11,17 @@ class EventNewsFeed
cache.regenerate cache.regenerate
end end
end end
def self.create_feed_cache(bulletin=nil,bulletin_feed=nil) def self.create_feed_cache(event_news=nil,event_news_feed=nil)
Thread.new do Thread.new do
if !bulletin.nil? if !event_news.nil?
self.where(:tag_ids.in => Array(bulletin.tag_ids).collect{|v| v.to_s}).each do |bulletin_feed| self.where(:tag_ids.in => Array(event_news.tag_ids).collect{|v| v.to_s}).each do |event_news_feed|
uid = bulletin_feed.uid uid = event_news_feed.uid
EventNewsCache.where(:uid => uid).each do |cache| EventNewsCache.where(:uid => uid).each do |cache|
cache.regenerate cache.regenerate
end end
end end
elsif !bulletin_feed.nil? elsif !event_news_feed.nil?
uid = bulletin_feed.uid uid = event_news_feed.uid
EventNewsCache.where(:uid => uid).each do |cache| EventNewsCache.where(:uid => uid).each do |cache|
cache.regenerate cache.regenerate
end end
@ -122,8 +122,8 @@ class EventNewsFeed
a["author"] = author a["author"] = author
a["params"] = anns.to_param a["params"] = anns.to_param
a["subtitle_ann"] = anns.subtitle if anns.display_subtitle? a["subtitle_ann"] = anns.subtitle if anns.display_subtitle?
a["bulletin_links"] = [] a["event_news_links"] = []
a["bulletin_files"] = [] a["event_news_files"] = []
a["event_carousel_images"] = anns.event_carousel_images.map{|image| {"src"=>"#{base_url}" + image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }} a["event_carousel_images"] = anns.event_carousel_images.map{|image| {"src"=>"#{base_url}" + image.file.url,"description"=>image.description.to_s,"description_text"=>image.description_text }}
a["external_link"] = anns["is_external_link"] ? anns.external_link : nil a["external_link"] = anns["is_external_link"] ? anns.external_link : nil
anns.tags.each do |tag| anns.tags.each do |tag|
@ -139,18 +139,18 @@ class EventNewsFeed
category_titles << {"title_translations" => cat.title_translations} category_titles << {"title_translations" => cat.title_translations}
end end
a["category"] = {"title_translations" => (cat.title_translations rescue {})} a["category"] = {"title_translations" => (cat.title_translations rescue {})}
anns.bulletin_links.each do |bl| anns.event_news_links.each do |bl|
b = {} b = {}
b["url"] = bl.url b["url"] = bl.url
b["title_translations"] = bl.title_translations b["title_translations"] = bl.title_translations
a["bulletin_links"] << b a["event_news_links"] << b
end end
anns.bulletin_files.each do |bf| anns.event_news_files.each do |bf|
b = {} b = {}
b["description_translations"] = bf.description_translations b["description_translations"] = bf.description_translations
b["title_translations"] = bf.title_translations b["title_translations"] = bf.title_translations
b["url"] = ("#{base_url}" + bf.file.url rescue "") b["url"] = ("#{base_url}" + bf.file.url rescue "")
a["bulletin_files"] << b a["event_news_files"] << b
end end
all_anns << a all_anns << a
end end