diff --git a/app/services/shixuns_service.rb b/app/services/shixuns_service.rb index 69bbc431..b7834ea7 100644 --- a/app/services/shixuns_service.rb +++ b/app/services/shixuns_service.rb @@ -119,6 +119,9 @@ class ShixunsService @children_list = [] # 目前只取十个,不多N+1问题不大 # 需要彻底解决则需要改数据路结构,比如Nested算法可以解决 + unless current_user.admin? + discusses = discusses.where(:hidden => false) + end if discusses.present? discusses.each do |d| # 总点赞数 diff --git a/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb b/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb new file mode 100644 index 00000000..9e026906 --- /dev/null +++ b/db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb @@ -0,0 +1,8 @@ +class ModifyHiddenDefualtForDiscusses < ActiveRecord::Migration + def up + change_column :discusses, :hidden, :boolean, :default => true + end + + def down + end +end