diff options
Diffstat (limited to 'app/finders/environments_finder.rb')
-rw-r--r-- | app/finders/environments_finder.rb | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/app/finders/environments_finder.rb b/app/finders/environments_finder.rb index 419be46fafe..29c00e4b2c2 100644 --- a/app/finders/environments_finder.rb +++ b/app/finders/environments_finder.rb @@ -47,6 +47,19 @@ class EnvironmentsFinder end # rubocop: enable CodeReuse/ActiveRecord + # This method will eventually take the place of `#execute` as an + # efficient way to get relevant environment entries. + # Currently, `#execute` method has a serious technical debt and + # we will likely rework on it in the future. + # See more https://gitlab.com/gitlab-org/gitlab-ce/issues/63381 + def find + environments = project.environments + environments = by_name(environments) + environments = by_search(environments) + + environments + end + private def ref @@ -56,4 +69,20 @@ class EnvironmentsFinder def commit params[:commit] end + + def by_name(environments) + if params[:name].present? + environments.for_name(params[:name]) + else + environments + end + end + + def by_search(environments) + if params[:search].present? + environments.for_name_like(params[:search], limit: nil) + else + environments + end + end end |