From a0ea38196bf30584d50193c75de5a219da4998aa Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Wed, 5 Jun 2019 14:53:41 +0800 Subject: [PATCH] =?UTF-8?q?=E9=9A=90=E8=97=8F=E7=9A=84=E5=AE=9E=E8=AE=AD?= =?UTF-8?q?=E9=99=A4=E8=B6=85=E7=BA=A7=E7=AE=A1=E7=90=86=E5=91=98=E5=A4=96?= =?UTF-8?q?=EF=BC=8C=E5=85=B6=E4=BB=96=E4=BA=BA=E6=97=A0=E6=B3=95=E6=9F=A5?= =?UTF-8?q?=E7=9C=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/services/shixuns_service.rb | 3 +++ .../20190605063236_modify_hidden_defualt_for_discusses.rb | 8 ++++++++ 2 files changed, 11 insertions(+) create mode 100644 db/migrate/20190605063236_modify_hidden_defualt_for_discusses.rb 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