Commit 244966bf authored by Heinrich Lee Yu's avatar Heinrich Lee Yu

Merge branch 'ab-use-exists' into 'master'

Change queries from using count to limit

See merge request gitlab-org/gitlab!27028
parents 5000e4a4 1b93bf96
...@@ -9,7 +9,7 @@ class Admin::Serverless::DomainsController < Admin::ApplicationController ...@@ -9,7 +9,7 @@ class Admin::Serverless::DomainsController < Admin::ApplicationController
end end
def create def create
if PagesDomain.instance_serverless.count > 0 if PagesDomain.instance_serverless.exists?
return redirect_to admin_serverless_domains_path, notice: _('An instance-level serverless domain already exists.') return redirect_to admin_serverless_domains_path, notice: _('An instance-level serverless domain already exists.')
end end
...@@ -31,7 +31,7 @@ class Admin::Serverless::DomainsController < Admin::ApplicationController ...@@ -31,7 +31,7 @@ class Admin::Serverless::DomainsController < Admin::ApplicationController
end end
def destroy def destroy
if domain.serverless_domain_clusters.count > 0 if domain.serverless_domain_clusters.exists?
return redirect_to admin_serverless_domains_path, return redirect_to admin_serverless_domains_path,
status: :conflict, status: :conflict,
notice: _('Domain cannot be deleted while associated to one or more clusters.') notice: _('Domain cannot be deleted while associated to one or more clusters.')
......
...@@ -206,11 +206,11 @@ module API ...@@ -206,11 +206,11 @@ module API
conflict!('Email has already been taken') if params[:email] && conflict!('Email has already been taken') if params[:email] &&
User.by_any_email(params[:email].downcase) User.by_any_email(params[:email].downcase)
.where.not(id: user.id).count > 0 .where.not(id: user.id).exists?
conflict!('Username has already been taken') if params[:username] && conflict!('Username has already been taken') if params[:username] &&
User.by_username(params[:username]) User.by_username(params[:username])
.where.not(id: user.id).count > 0 .where.not(id: user.id).exists?
user_params = declared_params(include_missing: false) user_params = declared_params(include_missing: false)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment