Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-foss.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLee Tickett <lee@tickett.net>2019-06-24 15:18:40 +0300
committerKamil TrzciƄski <ayufan@ayufan.eu>2019-06-24 15:18:40 +0300
commitec66f1b5ca20764abe21524792480755b614dbc7 (patch)
tree3ec0bcd669e9d015687effe037c18a3acf389952 /app/finders
parentcf137da316175ed43a980f57e22a81c537a54169 (diff)
Add name & search parameters to project environments API
Diffstat (limited to 'app/finders')
-rw-r--r--app/finders/environments_finder.rb29
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