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
annc_depts = annc_depts_translations[I18n.default_locale.to_s] rescue []
end
if !bf.nil?
tags = bf.tag_ids
categories = bf.category_ids
if !(categories.empty? && tags.empty?)
anns_before_filter = Bulletin.is_approved_and_show
can_display_and_sorted_flag = false
if !dt.nil?
dt = DateTime.parse(dt)
dtt = dt + 1.day
anns_before_filter = anns_before_filter.where(:postdate.gt => dt, :postdate.lt => dtt)
elsif !startdt.blank? && enddt.blank?
startdt = DateTime.parse(startdt)
enddt = DateTime.now
anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
elsif !startdt.blank? && !enddt.blank?
startdt = DateTime.parse(startdt)
enddt = DateTime.parse(enddt) + 1.day
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
tags = bf.tag_ids
categories = bf.category_ids
if !(categories.empty? && tags.empty?)
anns_before_filter = Bulletin.is_approved_and_show
can_display_and_sorted_flag = false
if !dt.nil?
dt = DateTime.parse(dt)
dtt = dt + 1.day
anns_before_filter = anns_before_filter.where(:postdate.gt => dt, :postdate.lt => dtt)
elsif !startdt.blank? && enddt.blank?
startdt = DateTime.parse(startdt)
enddt = DateTime.now
anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
elsif !startdt.blank? && !enddt.blank?
startdt = DateTime.parse(startdt)
enddt = DateTime.parse(enddt) + 1.day
anns_before_filter = anns_before_filter.where(:postdate.gt => startdt, :postdate.lt => enddt)
else
anns_before_filter = Bulletin.is_approved_and_show
announcements = []
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
anns_before_filter = Bulletin.can_display_and_sorted
announcements = anns_before_filter.to_a
end
all_anns = []
tag_ids = []