From c9d4714ef8fb0e42ff6fd41d17e1cadc96dd1cad Mon Sep 17 00:00:00 2001 From: daiao <358551898@qq.com> Date: Thu, 11 Jul 2019 10:45:30 +0800 Subject: [PATCH] =?UTF-8?q?=E6=88=91=E7=9A=84=E5=AE=9E=E8=AE=AD=E6=8A=A5?= =?UTF-8?q?=E9=94=99?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/controllers/shixuns_controller.rb | 2 +- app/models/shixun.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/app/controllers/shixuns_controller.rb b/app/controllers/shixuns_controller.rb index 714351561..c237da5e2 100644 --- a/app/controllers/shixuns_controller.rb +++ b/app/controllers/shixuns_controller.rb @@ -76,7 +76,7 @@ class ShixunsController < ApplicationController @shixuns = @shixuns.order("shixuns.status = 2 desc, shixuns.publish_time #{bsort}") end - # 用id计数会快10+MS左右,随着数据的增加,性能会提升一些。 + # 用id计数会快10+MS左右,对于搜索的内容随着数据的增加,性能会提升一些。 @total_count = @shixuns.count("shixuns.id") ## 分页参数 diff --git a/app/models/shixun.rb b/app/models/shixun.rb index cb305efaf..afad10397 100644 --- a/app/models/shixun.rb +++ b/app/models/shixun.rb @@ -52,7 +52,7 @@ class Shixun < ApplicationRecord end } - scope :visible, -> { where("status != -1") } + scope :visible, -> { where.not(status: -1) } scope :published, lambda{ where(status: 2) } scope :unhidden, lambda{ where(hidden: 0, status: 2) } scope :field_for_recommend, lambda{ select([:id, :name, :identifier, :myshixuns_count]) }