fix error

This commit is contained in:
邱博亞 2023-04-08 23:39:54 +08:00
parent 142300523c
commit 28b9abfd24
1 changed files with 34 additions and 36 deletions

View File

@ -74,44 +74,42 @@ class BulletinFeed
if tmp_enable_annc_dept if tmp_enable_annc_dept
annc_depts = annc_depts_translations[I18n.default_locale.to_s] rescue [] annc_depts = annc_depts_translations[I18n.default_locale.to_s] rescue []
end end
if !bf.nil? tags = bf.tag_ids
tags = bf.tag_ids categories = bf.category_ids
categories = bf.category_ids if !(categories.empty? && tags.empty?)
if !(categories.empty? && tags.empty?) anns_before_filter = Bulletin.is_approved_and_show
anns_before_filter = Bulletin.is_approved_and_show can_display_and_sorted_flag = false
can_display_and_sorted_flag = false if !dt.nil?
if !dt.nil? dt = DateTime.parse(dt)
dt = DateTime.parse(dt) dtt = dt + 1.day
dtt = dt + 1.day anns_before_filter = anns_before_filter.where(:postdate.gt => dt, :postdate.lt => dtt)
anns_before_filter = anns_before_filter.where(:postdate.gt => dt, :postdate.lt => dtt) elsif !startdt.blank? && enddt.blank?
elsif !startdt.blank? && enddt.blank? startdt = DateTime.parse(startdt)
startdt = DateTime.parse(startdt) enddt = DateTime.now
enddt = DateTime.now anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt) elsif !startdt.blank? && !enddt.blank?
elsif !startdt.blank? && !enddt.blank? startdt = DateTime.parse(startdt)
startdt = DateTime.parse(startdt) enddt = DateTime.parse(enddt) + 1.day
enddt = DateTime.parse(enddt) + 1.day anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
else
can_display_and_sorted_flag = true
end
if !tags.empty?
anns_before_filter = anns_before_filter.filter_by_tags(tags)
end
if !categories.empty?
anns_before_filter = anns_before_filter.filter_by_categories(categories,paginate=false)
end
anns_before_filter.selector = {"$and"=>[anns_before_filter.selector,{"$or"=>(I18n.available_locales.map{|v| {"title.#{v}"=>{"$nin"=>["", nil]}}})}]}
if can_display_and_sorted_flag
announcements = anns_before_filter.valid_time_range.to_a
else
announcements = anns_before_filter.to_a
end
else else
anns_before_filter = Bulletin.is_approved_and_show can_display_and_sorted_flag = true
announcements = []
end end
if !tags.empty?
anns_before_filter = anns_before_filter.filter_by_tags(tags)
end
if !categories.empty?
anns_before_filter = anns_before_filter.filter_by_categories(categories,paginate=false)
end
anns_before_filter.selector = {"$and"=>[anns_before_filter.selector,{"$or"=>(I18n.available_locales.map{|v| {"title.#{v}"=>{"$nin"=>["", nil]}}})}]}
if can_display_and_sorted_flag
announcements = anns_before_filter.valid_time_range.to_a
else
announcements = anns_before_filter.to_a
end
else
anns_before_filter = Bulletin.can_display_and_sorted
announcements = anns_before_filter.to_a
end end
all_anns = [] all_anns = []
tag_ids = [] tag_ids = []