项目列表默认查询时count性能问题处理
This commit is contained in:
parent
db845e7df0
commit
9da61bd69e
|
@ -39,9 +39,10 @@ class ProjectsController < ApplicationController
|
||||||
|
|
||||||
category_id = params[:category_id]
|
category_id = params[:category_id]
|
||||||
@total_count =
|
@total_count =
|
||||||
if category_id.blank?
|
if category_id.blank? && params[:search].blank?
|
||||||
# ps = ProjectStatistic.first
|
# 默认查询时count性能问题处理
|
||||||
# ps.common_projects_count + ps.mirror_projects_count unless ps.blank?
|
ProjectCategory.sum("projects_count") - Project.visible.joins("left join organization_extensions on organization_extensions.organization_id = projects.user_id").where("organization_extensions.visibility =2").count
|
||||||
|
elsif params[:search].present?
|
||||||
@projects.total_count
|
@projects.total_count
|
||||||
else
|
else
|
||||||
cate = ProjectCategory.find_by(id: category_id)
|
cate = ProjectCategory.find_by(id: category_id)
|
||||||
|
|
Loading…
Reference in New Issue