diff options
author | Lee Tickett <lee@tickett.net> | 2019-06-24 12:18:40 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-06-24 12:18:40 +0000 |
commit | ec66f1b5ca20764abe21524792480755b614dbc7 (patch) | |
tree | 3ec0bcd669e9d015687effe037c18a3acf389952 /app/finders | |
parent | cf137da316175ed43a980f57e22a81c537a54169 (diff) | |
download | gitlab-ce-ec66f1b5ca20764abe21524792480755b614dbc7.tar.gz |
Add name & search parameters to project environments API
Diffstat (limited to 'app/finders')
-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 |