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 ...@@ -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