diff options
author | Jochen Topf <jochen@topf.org> | 2014-05-18 22:08:28 +0200 |
---|---|---|
committer | Jochen Topf <jochen@topf.org> | 2014-05-18 22:08:28 +0200 |
commit | 19e5943636ade0f6dc1767005f13c6470bbfa96e (patch) | |
tree | 963234b573bf87e4cbe7684ee7554515847c44a3 /web/lib | |
parent | 7a944d65082af044888e3c38093bfadf0d0dbf3d (diff) | |
download | taginfo-19e5943636ade0f6dc1767005f13c6470bbfa96e.tar taginfo-19e5943636ade0f6dc1767005f13c6470bbfa96e.tar.gz |
Disable search when search field is empty.
Diffstat (limited to 'web/lib')
-rw-r--r-- | web/lib/api/v4/search.rb | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/web/lib/api/v4/search.rb b/web/lib/api/v4/search.rb index e2015c5..c159563 100644 --- a/web/lib/api/v4/search.rb +++ b/web/lib/api/v4/search.rb @@ -143,6 +143,17 @@ class Taginfo < Sinatra::Base }) do query = params[:query] + # searching for the empty string is very expensive, so we'll just return an empty result + if query == '' + return JSON.generate({ + :page => 0, + :rp => 0, + :total => 0, + :url => request.url, + :data => [] + }, json_opts(params[:format])) + end + total = @db.count('search.ftsearch'). condition_if("value MATCH ?", query). get_first_value().to_i |