add invalid date for page cache

This commit is contained in:
邱博亞 2022-03-17 15:36:31 +08:00
parent 0af1d8c145
commit 36b8502168
2 changed files with 14 additions and 4 deletions

View File

@ -7,7 +7,7 @@ class AnnouncementFeedsController < ApplicationController
enddt = params[:end].blank? ? nil : params[:end]
dt = params[:date].blank? ? nil : params[:date]
feed_cache = BulletinFeedCache.where(uid: uid, start: startdt, end: enddt, date: dt)
feed_cache.all_of({:invalid_date.ne=>nil,:invalid_date.lte => Time.now}).destroy
feed_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy
count = feed_cache.count
if count > 1
feed_cache.limit(count-1).destroy

View File

@ -505,7 +505,7 @@ class AnnouncementsController < ApplicationController
widget_data_count = OrbitHelper.widget_data_count
anns_cache = AnnsCache.where(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s)
devide_flag = (!(defined? SiteFeed).nil?)
anns_cache.all_of({:invalid_date.ne=>nil,:invalid_date.lte => Time.now}).destroy
anns_cache.all_of([{:invalid_date.ne=>nil},{:invalid_date.lte => Time.now}]).destroy
count = anns_cache.count
if count > 1
anns_cache.limit(count-1).destroy
@ -531,6 +531,7 @@ class AnnouncementsController < ApplicationController
AnnsCache.create(parent_id: subpart.id.to_s + cats.to_s + tags.to_s + widget_data_count.to_s,locale: I18n.locale.to_s,filter_result: anns,invalid_date: invalid_date)
end
else
invalid_date = Time.now + 3.second
if devide_flag
anns = sorted_anns.sample(widget_data_count)
top_anns = anns.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
@ -540,11 +541,20 @@ class AnnouncementsController < ApplicationController
end
end
elsif devide_flag
now_anns = anns_cache.first.filter_result
c = anns_cache.first
now_anns = c.filter_result
invalid_date = c.invalid_date
top_anns = now_anns[:top]
not_top_anns = now_anns[:not_top]
else
anns = anns_cache.first.filter_result
c = anns_cache.first
invalid_date = c.invalid_date
anns = c.filter_result
end
if @page_invalid_time.nil?
@page_invalid_time = invalid_date
elsif !invalid_date.nil? && @page_invalid_time>invalid_date
@page_invalid_time = invalid_date
end
if devide_flag
feeds_anns = get_feed_announcements("widget",nil,cats,widget_data_count - top_anns.count)