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:
Diffstat (limited to 'lib/gitlab/empty_search_results.rb')
-rw-r--r--lib/gitlab/empty_search_results.rb28
1 files changed, 28 insertions, 0 deletions
diff --git a/lib/gitlab/empty_search_results.rb b/lib/gitlab/empty_search_results.rb
new file mode 100644
index 00000000000..71a78cb297b
--- /dev/null
+++ b/lib/gitlab/empty_search_results.rb
@@ -0,0 +1,28 @@
+# frozen_string_literal: true
+
+module Gitlab
+ # This class has the same interface as SearchResults except
+ # it is empty and does not do any work.
+ #
+ # We use this when responding to abusive search requests.
+ class EmptySearchResults
+ def initialize(*)
+ end
+
+ def objects(*)
+ Kaminari.paginate_array([])
+ end
+
+ def formatted_count(*)
+ '0'
+ end
+
+ def highlight_map(*)
+ {}
+ end
+
+ def aggregations(*)
+ []
+ end
+ end
+end