修改分类数量显示bug
This commit is contained in:
parent
73ad4b8a96
commit
b30510bf3d
|
@ -8,7 +8,7 @@ class ProjectCategoriesController < ApplicationController
|
|||
if is_admin
|
||||
projects = Project.all
|
||||
elsif current_user&.logged?
|
||||
projects = Project.joins(:members).where.not("projects.is_public = ? and (projects.user_id != ? or members.user_id != ?)", false, current_user.id,current_user.id ).distinct
|
||||
projects = Project.list_user_projects(current_user.id)
|
||||
else
|
||||
projects = Project.visible
|
||||
end
|
||||
|
|
|
@ -42,7 +42,8 @@ class ProjectsController < ApplicationController
|
|||
if is_admin
|
||||
projects = Project.all
|
||||
elsif current_user&.logged?
|
||||
projects = Project.joins(:members).where.not("projects.is_public = ? and (projects.user_id != ? or members.user_id != ?)", false, current_user.id,current_user.id ).distinct
|
||||
|
||||
projects = Project.list_user_projects(current_user.id)
|
||||
else
|
||||
projects = Project.visible
|
||||
end
|
||||
|
|
|
@ -101,4 +101,9 @@ class Project < ApplicationRecord
|
|||
str
|
||||
end
|
||||
|
||||
def self.list_user_projects(user_id)
|
||||
user_not_show = Project.joins(:members).where("projects.is_public = ? and (projects.user_id != ? or members.user_id != ?)", false, user_id,user_id).pluck(:id).uniq
|
||||
Project.where.not(id: user_not_show)
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
@ -13,7 +13,7 @@ class Projects::ListQuery < ApplicationQuery
|
|||
if params[:is_admin]
|
||||
projects = Project.all
|
||||
elsif params[:user_id].to_i != 2
|
||||
projects = Project.joins(:members).where.not("projects.is_public = ? and (projects.user_id != ? or members.user_id != ?)", false, params[:user_id].to_i,params[:user_id].to_i ).distinct
|
||||
projects = Project.list_user_projects(params[:user_id])
|
||||
else
|
||||
projects = Project.visible
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue