about summary refs log tree commit diff
path: root/app/controllers/api
diff options
context:
space:
mode:
authorEugen Rochko <eugen@zeonfederated.com>2016-11-12 14:49:28 +0100
committerEugen Rochko <eugen@zeonfederated.com>2016-11-12 14:49:28 +0100
commitafded319d2558369a025b1f3335cebacc9819881 (patch)
tree2e5c0cae17213c46faff3e25a07922338d0f1ce1 /app/controllers/api
parent09218d4c0152013750dd1c127d3c8267dc45f880 (diff)
Add limit to search results
Diffstat (limited to 'app/controllers/api')
-rw-r--r--app/controllers/api/v1/accounts_controller.rb3
1 files changed, 2 insertions, 1 deletions
diff --git a/app/controllers/api/v1/accounts_controller.rb b/app/controllers/api/v1/accounts_controller.rb
index 9b02c9981..9573326ef 100644
--- a/app/controllers/api/v1/accounts_controller.rb
+++ b/app/controllers/api/v1/accounts_controller.rb
@@ -92,7 +92,8 @@ class Api::V1::AccountsController < ApiController
   end
 
   def search
-    @accounts = SearchService.new.call(params[:q], params[:resolve] == 'true')
+    limit = params[:limit] ? [DEFAULT_ACCOUNTS_LIMIT, params[:limit].to_i].min : DEFAULT_ACCOUNTS_LIMIT
+    @accounts = SearchService.new.call(params[:q], limit, params[:resolve] == 'true')
     render action: :index
   end