From bb5e98c6b1ef2c9bb18d2669b88a48da1610f20e Mon Sep 17 00:00:00 2001 From: chiu Date: Thu, 28 May 2020 15:30:16 +0800 Subject: [PATCH] fix error --- app/controllers/announcements_controller.rb | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/app/controllers/announcements_controller.rb b/app/controllers/announcements_controller.rb index 14bdf14..e5204d8 100644 --- a/app/controllers/announcements_controller.rb +++ b/app/controllers/announcements_controller.rb @@ -142,7 +142,13 @@ class AnnouncementsController < ApplicationController AnnsCache.create(parent_id: subpart.id.to_s,locale: I18n.locale.to_s,filter_result: anns) end else - anns = sorted_anns.sample(widget_data_count).map{|v| data_to_human_type(v)} + if devide_flag + anns = sorted_anns.sample(widget_data_count).map{|v| data_to_human_type(v)} + top_anns = anns.select{|v| v.is_top} + not_top_anns = anns.select{|v| !v.is_top} + else + anns = sorted_anns.sample(widget_data_count).map{|v| data_to_human_type(v)} + end end elsif devide_flag now_anns = anns_cache.first.filter_result