修改首页搜索后的显示数量不对的问题
This commit is contained in:
parent
2b24bc9724
commit
441f8eb877
|
@ -9,6 +9,7 @@ class ProjectsController < ApplicationController
|
||||||
is_admin = current_user && current_user&.admin?
|
is_admin = current_user && current_user&.admin?
|
||||||
|
|
||||||
scope = Projects::ListQuery.call(params.merge(is_admin: is_admin, user_id: current_user.try(:id)))
|
scope = Projects::ListQuery.call(params.merge(is_admin: is_admin, user_id: current_user.try(:id)))
|
||||||
|
|
||||||
@total_count = scope.size
|
@total_count = scope.size
|
||||||
@projects = paginate(scope)
|
@projects = paginate(scope)
|
||||||
end
|
end
|
||||||
|
|
|
@ -29,7 +29,7 @@ class Project < ApplicationRecord
|
||||||
|
|
||||||
after_save :check_project_members
|
after_save :check_project_members
|
||||||
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
scope :project_statics_select, -> {select(:id,:name, :is_public, :identifier, :status, :project_type, :user_id, :forked_count, :visits, :project_category_id, :project_language_id, :license_id, :ignore_id, :watchers_count, :created_on)}
|
||||||
scope :no_anomory_projects, -> {where("projects.user_id != ?", 2)}
|
scope :no_anomory_projects, -> {where("projects.user_id is not null and projects.user_id != ?", 2)}
|
||||||
|
|
||||||
|
|
||||||
# 创建者
|
# 创建者
|
||||||
|
|
|
@ -23,7 +23,7 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
else
|
else
|
||||||
projects = Project.visible #匿名用户的项目
|
projects = Project.visible #匿名用户的项目
|
||||||
end
|
end
|
||||||
scope = projects.no_anomory_projects.includes(:project_category, :project_language, :repository, owner: :user_extension).like(params[:search])
|
scope = projects.includes(:project_category, :project_language, :repository, owner: :user_extension).like(params[:search]).no_anomory_projects
|
||||||
.with_project_type(params[:project_type])
|
.with_project_type(params[:project_type])
|
||||||
.with_project_category(params[:category_id])
|
.with_project_category(params[:category_id])
|
||||||
.with_project_language(params[:language_id])
|
.with_project_language(params[:language_id])
|
||||||
|
@ -32,6 +32,7 @@ class Projects::ListQuery < ApplicationQuery
|
||||||
sort_direction = params[:sort_direction] || "desc"
|
sort_direction = params[:sort_direction] || "desc"
|
||||||
scope = scope.order("projects.#{sort} #{sort_direction}")
|
scope = scope.order("projects.#{sort} #{sort_direction}")
|
||||||
scope
|
scope
|
||||||
|
Rails.logger.info("######__________scope.size______________##########{scope.size}")
|
||||||
# custom_sort(scope, params[:sort_by], params[:sort_direction])
|
# custom_sort(scope, params[:sort_by], params[:sort_direction])
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue