Merge branch 'standalone_develop' into pre_trustie_server

This commit is contained in:
yystopf 2023-03-24 15:10:24 +08:00
commit c707f9c391
3 changed files with 13 additions and 1 deletions

View File

@ -680,6 +680,14 @@ class ApplicationController < ActionController::Base
relation.page(page).per(limit)
end
def kaminari_unlimit_paginate(relation)
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 9999) ? 9999 : limit.to_i
page = params[:page].to_i.zero? ? 1 : params[:page].to_i
relation.page(page).per(limit)
end
def kaminari_array_paginate(relation)
limit = params[:limit] || params[:per_page]
limit = (limit.to_i.zero? || limit.to_i > 20) ? 20 : limit.to_i

View File

@ -406,7 +406,7 @@ class UsersController < ApplicationController
is_current_admin_user = User.current.logged? && (current_user&.admin? || current_user.id == @user.id)
scope = Projects::ListMyQuery.call(params, @user,is_current_admin_user)
@total_count = scope.size
@projects = paginate(scope)
@projects = kaminari_unlimit_paginate(scope)
end

View File

@ -34,6 +34,10 @@ class Projects::ListMyQuery < ApplicationQuery
elsif params[:category].to_s == "forked" #我fork的
fork_ids = user.fork_users.select(:id, :fork_project_id).pluck(:fork_project_id)
projects = projects.where(id: fork_ids)
elsif params[:category].to_s == "admin"
normal_projects = projects.joins(members: :roles).where(members: {user_id: user.id}, roles: {name: %w(Manager)}).to_sql
org_projects = projects.joins(team_projects: [team: :team_users]).where(teams: {authorize: "owner"},team_users: {user_id: user.id}).to_sql
projects = Project.from("( #{ normal_projects} UNION #{ org_projects } ) AS projects").distinct
# elsif params[:category].to_s == "public"
# projects = projects.visible.joins(:members).where(members: { user_id: user.id })
# elsif params[:category].to_s == "private"