Commit baed79a7 authored by Dylan Griffith's avatar Dylan Griffith

Avoid join in PipelinesFinder#by_username

When we move `ci_*` tables to a separate database this join will not be
possible. This was extracted from
https://gitlab.com/gitlab-org/gitlab/-/merge_requests/62092 .
parent 39393b4e
......@@ -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