From 4e21213602e3ade1822c34a2ed49506d090ce557 Mon Sep 17 00:00:00 2001 From: BOHUNG Date: Mon, 24 Feb 2020 18:19:36 +0800 Subject: [PATCH] Fix is_top's Bulletin repeated appear in index pages. --- app/helpers/announcements_helper.rb | 11 ----------- 1 file changed, 11 deletions(-) diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 73dd55f..7bc1971 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -47,7 +47,6 @@ module AnnouncementsHelper locale = OrbitHelper.get_site_locale.to_s page = Page.where(url:params['url']).first feeds_anns = [] - top_anns = [] tags = page.tags if !tags.blank? announcements = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil).can_display.is_approved.filter_by_categories(page.categories || [],false).filter_by_tags(tags).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count).to_a @@ -61,18 +60,9 @@ module AnnouncementsHelper end end # (OrbitHelper.page_number == 1 or OrbitHelper.page_number.nil?) && - if !params["source"].present? - if !tags.blank? - top_anns = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :is_top => true).and(:title.ne => nil).can_display.filter_by_categories(page.categories || [],false).filter_by_tags(tags).to_a - else - top_anns = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil], :is_top => true).and(:title.ne => nil).can_display.filter_by_categories(page.categories || [],false).filter_by_tags.to_a - end - end - if !feeds_anns.blank? announcements = announcements.concat(feeds_anns) sorted = announcements.sort{ |k,v| v["postdate"] <=> k["postdate"] } - sorted = top_anns + sorted if params["keywords"].present? sorted = sorted.find_all{|anns| if anns["source-site"].present? @@ -93,7 +83,6 @@ module AnnouncementsHelper end sorted = Kaminari.paginate_array(sorted).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue [] else - announcements = top_anns + announcements if params["keywords"].present? announcements = announcements.find_all{|anns| /#{params[:keywords].to_s}/i.match anns.title} end