mirror of
https://gitlink.org.cn/Gitlink/forgeplus.git
synced 2026-05-02 19:30:48 +08:00
修改首页搜索后的显示数量不对的问题
This commit is contained in:
@@ -9,6 +9,7 @@ class ProjectsController < ApplicationController
|
||||
is_admin = current_user && current_user&.admin?
|
||||
|
||||
scope = Projects::ListQuery.call(params.merge(is_admin: is_admin, user_id: current_user.try(:id)))
|
||||
|
||||
@total_count = scope.size
|
||||
@projects = paginate(scope)
|
||||
end
|
||||
|
||||
@@ -29,7 +29,7 @@ class Project < ApplicationRecord
|
||||
|
||||
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 :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
|
||||
projects = Project.visible #匿名用户的项目
|
||||
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_category(params[:category_id])
|
||||
.with_project_language(params[:language_id])
|
||||
@@ -32,6 +32,7 @@ class Projects::ListQuery < ApplicationQuery
|
||||
sort_direction = params[:sort_direction] || "desc"
|
||||
scope = scope.order("projects.#{sort} #{sort_direction}")
|
||||
scope
|
||||
Rails.logger.info("######__________scope.size______________##########{scope.size}")
|
||||
# custom_sort(scope, params[:sort_by], params[:sort_direction])
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user