diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 8bfd432..b9f08d6 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -2,9 +2,7 @@ class AnnouncementsController < ApplicationController include AnnouncementsHelper def index Bulletin.remove_expired_status - announcements,sorted = get_sorted_annc - total_pages = sorted.total_pages - + announcements,sorted,total_pages = get_sorted_annc anns = [] sorted.each do |a| if !a["source-site"].present? diff --git a/app/helpers/announcements_helper.rb b/app/helpers/announcements_helper.rb index 7bc1971..f372776 100644 --- a/app/helpers/announcements_helper.rb +++ b/app/helpers/announcements_helper.rb @@ -93,8 +93,23 @@ module AnnouncementsHelper end } end - sorted = Kaminari.paginate_array(announcements).page(OrbitHelper.page_number).per(OrbitHelper.page_data_count) rescue [] + sorted = Kaminari.paginate_array(announcements).page(1).per(OrbitHelper.page_data_count) rescue [] end - [announcements,sorted] + begin + if !tags.blank? + annc_count = 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).count + else + if !params["source"].present? + annc_count = Bulletin.where(:title.ne => "",:is_preview.in=>[false,nil]).and(:title.ne => nil, :is_top.ne => true).can_display.is_approved.filter_by_categories(page.categories || [],false).filter_by_tags.count + annc_count += get_feed_announcements("index").count + else + annc_count = get_feed_announcements("index",params["source"]).count + end + end + total_pages = (annc_count * 1.0 / OrbitHelper.page_data_count).ceil + rescue + total_pages = 1 + end + [announcements,sorted,total_pages] end end