cache the whole bulletin content

This commit is contained in:
chiu 2020-05-06 18:23:04 +08:00
parent d81e9d40bd
commit 9f7dfafe95
1 changed files with 2 additions and 4 deletions

View File

@ -129,14 +129,12 @@ class AnnouncementsController < ApplicationController
if anns_cache.count > 1
anns_cache.destroy
end
AnnsCache.create(parent_id: subpart.id.to_s,locale: I18n.locale.to_s,filter_result: sorted_anns.pluck(:id))
AnnsCache.create(parent_id: subpart.id.to_s,locale: I18n.locale.to_s,filter_result: sorted_anns.to_a.to_yaml)
else
sorted_anns = sorted_anns.sample(widget_data_count)
end
else
sorted_ann_ids = anns_cache.first.filter_result
sorted_anns = Bulletin.find(sorted_ann_ids)
sorted_anns = sorted_ann_ids.map{|v1| sorted_anns.find{|v2| v2.id==v1}}
sorted_anns = YAML.load(anns_cache.first.filter_result)
end
if (defined? SiteFeed).nil? || is_random
anns = sorted_anns.map{|v| data_to_human_type(v)}