fix error

This commit is contained in:
邱博亞 2021-12-30 18:24:21 +08:00
parent c45767adbc
commit 7f4db2cb7d
1 changed files with 5 additions and 2 deletions

View File

@ -29,7 +29,7 @@ class SiteFeedAnnc
def cache_annc(force_refresh=false,locales=nil,trans=nil)
feed = SiteFeed.find(self.feed_id)
anns = feed.get_annc(force_refresh)
cat = self.category_title
cat = self[:category_title]
if locales.nil?
locales = Site.first.in_use_locales rescue I18n.available_locales
end
@ -162,6 +162,7 @@ class SiteFeedAnnc
end
def self.get_feed_cache(channel_key,merge_with_category=nil,site_source=nil,locale=I18n.locale.to_s,is_widget=false,max_len=nil)
locale = I18n.locale.to_s
max_len = ((max_len.to_i < 0 rescue true) ? 0 : max_len.to_i)
if max_len > 0
match_cond = {"channel_key"=>channel_key}
@ -187,6 +188,7 @@ class SiteFeedAnnc
end
self.collection.aggregate(pipeline).collect do |data|
tmp = data['data']
tmp['category'] = tmp['category'][locale]
if tmp["link_to_show"].nil?
if !is_widget
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? (tmp["source_url"] + tmp["show_url"]) : OrbitHelper.url_to_show(tmp["params"]) rescue ''
@ -209,6 +211,7 @@ class SiteFeedAnnc
Array(self[:all_contents_for_feed][locale.to_s]).collect do |v|
tmp = v
next if tmp["is_hidden"] || (!tmp["postdate"].nil? && tmp["postdate"]<Time.now) || tmp['title'].blank?
tmp['category'] = tmp['category'][locale]
if tmp["link_to_show"].nil?
if !is_widget
tmp["link_to_show"] = UseSourceUrl && tmp["show_url"] ? (tmp["source_url"] + tmp["show_url"]) : OrbitHelper.url_to_show(tmp["params"]) rescue ''
@ -226,6 +229,6 @@ class SiteFeedAnnc
Category.find(self.merge_with_category) rescue nil
end
def category_title
self[:category_title][I18n.locale]
self[:category_title][I18n.locale.to_s]
end
end