Commit 3eb13492 authored by Stan Hu's avatar Stan Hu

Merge branch 'remove-joins-pipelinesfinder-by-username' into 'master'

Avoid join in PipelinesFinder#by_username

See merge request gitlab-org/gitlab!66023
parents fe356751 baed79a7
...@@ -119,11 +119,12 @@ module Ci ...@@ -119,11 +119,12 @@ module Ci
# rubocop: disable CodeReuse/ActiveRecord # rubocop: disable CodeReuse/ActiveRecord
def by_username(items) def by_username(items)
if params[:username].present? return items unless params[:username].present?
items.joins(:user).where(users: { username: params[:username] })
else user_id = User.by_username(params[:username]).pluck_primary_key.first
items return Ci::Pipeline.none unless user_id
end
items.where(user_id: user_id)
end end
# rubocop: enable CodeReuse/ActiveRecord # rubocop: enable CodeReuse/ActiveRecord
......
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