fix bug for anns cache
This commit is contained in:
1 parent
427222df41
commit
6ff4eecbc1
3 files changed
+20
-11
No files matched your search
@@ -59,6 +59,9 @@ class AnnouncementsController < ApplicationController
|
||||
a
|
||||
end
|
||||
end
|
||||
if anns.count == 0 && params.any?{|k,v| v.class==Array ? v.any?{|v1| v1.to_s.match(/\*|\(|\)/)} : v.to_s.match(/\*|\(|\)/)}
|
||||
return nil
|
||||
end
|
||||
#If no data , hide title&table
|
||||
if sorted.count == 0
|
||||
display = "hide"
|
||||
@@ -447,25 +450,29 @@ class AnnouncementsController < ApplicationController
|
||||
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)
|
||||
set_image_version_for_widget()
|
||||
devide_flag = (!(defined? SiteFeed).nil?)
|
||||
if anns_cache.count != 1 || is_random
|
||||
anns_cache.where(:invalid_date.lte => Time.now).destroy
|
||||
if anns_cache.count > 1
|
||||
anns_cache.skip(1).destroy
|
||||
end
|
||||
if anns_cache.count == 0 || is_random
|
||||
Bulletin.remove_expired_status
|
||||
uid = OrbitHelper.params[:uid] rescue ""
|
||||
sorted_anns = Bulletin.where(:title.nin => ["",nil],:is_preview.in=>[false,nil], :uid.ne => uid)
|
||||
.can_display_and_sorted.is_approved
|
||||
.filter_by_widget_categories(cats,false).filter_by_tags(tags)
|
||||
anns_for_locale = Bulletin.where(:title.nin => ["",nil], :uid.ne => uid).is_approved.filter_cats_and_tags(cats,tags)
|
||||
sorted_anns = anns_for_locale.can_display_and_sorted
|
||||
if !is_random
|
||||
sorted_anns = sorted_anns.limit(widget_data_count)
|
||||
if anns_cache.count > 1
|
||||
anns_cache.destroy
|
||||
end
|
||||
first_deadline = sorted_anns.pluck(:deadline).compact.sort[0]
|
||||
first_postdate = anns_for_locale.open_in_future.limit(1).pluck(:postdate)[0]
|
||||
invalid_date = [first_postdate,first_deadline].compact.sort[0]
|
||||
|
||||
if devide_flag
|
||||
now_anns = sorted_anns.to_a
|
||||
top_anns = now_anns.select{|v| v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
||||
not_top_anns = now_anns.select{|v| !v.is_top}.map{|v| data_to_human_type(v,set_tags)}
|
||||
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: {top: top_anns,not_top: not_top_anns})
|
||||
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: {top: top_anns,not_top: not_top_anns},invalid_date: invalid_date)
|
||||
else
|
||||
anns = sorted_anns.map{|v| data_to_human_type(v,set_tags)}
|
||||
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)
|
||||
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
|
||||
if devide_flag
|
||||
|
||||
Reference in new issue
Block a user