This commit is contained in:
chiu 2021-09-15 20:50:30 +08:00
parent e442c0060a
commit 945841a5fb
2 changed files with 19 additions and 15 deletions

View File

@ -138,6 +138,7 @@ class AnnouncementsController < ApplicationController
def pack_data(is_random=false)
cats = OrbitHelper.widget_categories || []
tags = OrbitHelper.widget_tags || []
tags = ['all'] if tags.blank?
subpart = OrbitHelper.get_current_widget
get_tabs_option
anns = []
@ -147,11 +148,11 @@ class AnnouncementsController < ApplicationController
else
if cats.count != 1 || tags == ["all"]
cats.each do |cat|
anns = anns + get_anncs_for_pack_data([cat],tags,'')
anns = anns + get_anncs_for_pack_data([cat],tags,'',is_random)
end
else
tags.each do |tag|
anns = anns + get_anncs_for_pack_data(cats,[tag],tag)
anns = anns + get_anncs_for_pack_data(cats,[tag],tag,is_random)
end
use_tag = true
end
@ -500,8 +501,8 @@ class AnnouncementsController < ApplicationController
anns = anns_cache.first.filter_result
end
if devide_flag
feeds_anns = get_feed_announcements("widget")
top_anns = top_anns + feeds_anns.select{|v| v['is_top']}
feeds_anns = get_feed_announcements("widget",nil,cats,widget_data_count - top_anns.count)
top_anns = top_anns + feeds_anns.select{|v| v['is_top'] == true}
top_anns = top_anns.sort_by { |a| tmp=a["postdate"].blank?;[tmp ? 0 : 1, tmp ? nil : a["postdate"].to_time] }.reverse
rest_count = widget_data_count - top_anns.count
if rest_count <= 0

View File

@ -85,8 +85,9 @@ module AnnouncementsHelper
"img_description" => desc
}
end
def get_feed_annc(type,site_source,locale)
def get_feed_annc(type,site_source,locale,categories=nil)
ma_key = 'announcement'
if categories.nil?
if type == "index"
categories = Array(OrbitHelper.page_categories)
elsif type == "widget"
@ -94,6 +95,8 @@ module AnnouncementsHelper
else
categories = []
end
end
categories = ["all"] if categories.length==0
if categories.include?("all")
feeds = SiteFeedAnnc.where(:channel_key => ma_key)
else
@ -109,10 +112,10 @@ module AnnouncementsHelper
end
data
end
def get_feed_announcements(type,site_source=nil)
def get_feed_announcements(type,site_source=nil,categories=nil,max_len=nil)
locale = OrbitHelper.get_site_locale.to_s
if !(defined? SiteFeedAnnc).nil?
fans = get_feed_annc(type,site_source,locale)
fans = get_feed_annc(type,site_source,locale,categories)
else
feed_anns = OrbitHelper.get_feed_for_module(type)
fans = []
@ -226,7 +229,7 @@ module AnnouncementsHelper
end
if !(defined? SiteFeed).nil?
if @type != "show_widget"
feeds_anns = get_feed_announcements("index")
feeds_anns = get_feed_announcements("index",nil,nil,page_number*page_data_count)
else
feeds_anns = []
end
@ -234,7 +237,7 @@ module AnnouncementsHelper
else
announcements = []
if @type != "show_widget"
feeds_anns = get_feed_announcements("index",params["source"])
feeds_anns = get_feed_announcements("index",params["source"],nil,page_number*page_data_count)
else
feeds_anns = []
end