accelerate feed

This commit is contained in:
邱博亞 2021-11-09 18:10:46 +08:00
parent 563dc35b8e
commit 2e339827c5
1 changed files with 3 additions and 15 deletions

View File

@ -61,7 +61,7 @@ module AnnouncementsHelper
"img_description" => desc "img_description" => desc
} }
end end
def get_feed_annc(type,site_source,locale,categories=nil) def get_feed_annc(type,site_source,locale,categories=nil,max_len=nil)
ma_key = 'announcement' ma_key = 'announcement'
if categories.nil? if categories.nil?
if type == "index" if type == "index"
@ -73,25 +73,13 @@ module AnnouncementsHelper
end end
end end
categories = ["all"] if categories.length==0 categories = ["all"] if categories.length==0
if categories.include?("all") data = SiteFeedAnnc.get_feed_cache(ma_key,categories,site_source,locale,type=='widget',max_len)
feeds = SiteFeedAnnc.where(:channel_key => ma_key)
else
feeds = SiteFeedAnnc.where(:channel_key => ma_key, :merge_with_category.in => categories)
end
if feeds.count > 0
temp_ids = []
data = feeds.collect do |feed|
feed.all_contents_for_feed(site_source,locale,type=='widget')
end.flatten.compact
else
data = []
end
data data
end end
def get_feed_announcements(type,site_source=nil,categories=nil,max_len=nil) def get_feed_announcements(type,site_source=nil,categories=nil,max_len=nil)
locale = OrbitHelper.get_site_locale.to_s locale = OrbitHelper.get_site_locale.to_s
if !(defined? SiteFeedAnnc).nil? if !(defined? SiteFeedAnnc).nil?
fans = get_feed_annc(type,site_source,locale,categories) fans = get_feed_annc(type,site_source,locale,categories,max_len)
else else
feed_anns = OrbitHelper.get_feed_for_module(type) feed_anns = OrbitHelper.get_feed_for_module(type)
fans = [] fans = []