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
# rubocop: disable CodeReuse/ActiveRecord
def by_username(items)
if params[:username].present?
items.joins(:user).where(users: { username: params[:username] })
else
items
end
return items unless params[:username].present?
user_id = User.by_username(params[:username]).pluck_primary_key.first
return Ci::Pipeline.none unless user_id
items.where(user_id: user_id)
end
# 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