add invalid date for page cache
This commit is contained in:
parent
0af1d8c145
commit
36b8502168
|
@ -7,7 +7,7 @@ class AnnouncementFeedsController < ApplicationController
|
||||||
enddt = params[:end].blank? ? nil : params[:end]
|
enddt = params[:end].blank? ? nil : params[:end]
|
||||||
dt = params[:date].blank? ? nil : params[:date]
|
dt = params[:date].blank? ? nil : params[:date]
|
||||||
feed_cache = BulletinFeedCache.where(uid: uid, start: startdt, end: enddt, date: dt)
|
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
|
count = feed_cache.count
|
||||||
if count > 1
|
if count > 1
|
||||||
feed_cache.limit(count-1).destroy
|
feed_cache.limit(count-1).destroy
|
||||||
|
|
|
@ -505,7 +505,7 @@ class AnnouncementsController < ApplicationController
|
||||||
widget_data_count = OrbitHelper.widget_data_count
|
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)
|
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?)
|
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
|
count = anns_cache.count
|
||||||
if count > 1
|
if count > 1
|
||||||
anns_cache.limit(count-1).destroy
|
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)
|
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
|
end
|
||||||
else
|
else
|
||||||
|
invalid_date = Time.now + 3.second
|
||||||
if devide_flag
|
if devide_flag
|
||||||
anns = sorted_anns.sample(widget_data_count)
|
anns = sorted_anns.sample(widget_data_count)
|
||||||
top_anns = anns.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
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
|
||||||
end
|
end
|
||||||
elsif devide_flag
|
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]
|
top_anns = now_anns[:top]
|
||||||
not_top_anns = now_anns[:not_top]
|
not_top_anns = now_anns[:not_top]
|
||||||
else
|
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
|
end
|
||||||
if devide_flag
|
if devide_flag
|
||||||
feeds_anns = get_feed_announcements("widget",nil,cats,widget_data_count - top_anns.count)
|
feeds_anns = get_feed_announcements("widget",nil,cats,widget_data_count - top_anns.count)
|
||||||
|
|
Loading…
Reference in New Issue