summaryrefslogtreecommitdiff
path: root/web
diff options
context:
space:
mode:
authorJochen Topf <jochen@topf.org>2011-10-22 15:08:26 +0200
committerJochen Topf <jochen@topf.org>2011-10-22 15:08:26 +0200
commit373a6ac381989a65b0eae9b7e11585ebb1b42cc5 (patch)
tree41c167e40840818f6701602c100c59da38ae5330 /web
parentd207cfb6790992214b697241986def1657aeb25f (diff)
downloadtaginfo-373a6ac381989a65b0eae9b7e11585ebb1b42cc5.tar
taginfo-373a6ac381989a65b0eae9b7e11585ebb1b42cc5.tar.gz
fix combinations table
Diffstat (limited to 'web')
-rw-r--r--web/lib/api/db.rb4
1 files changed, 2 insertions, 2 deletions
diff --git a/web/lib/api/db.rb b/web/lib/api/db.rb
index 3a3de71..e33c797 100644
--- a/web/lib/api/db.rb
+++ b/web/lib/api/db.rb
@@ -342,7 +342,7 @@ class Taginfo < Sinatra::Base
end
cq = @db.count('db.keypairs')
- total = (params[:query] != '' ? cq.condition("(key1 = ? AND key2 LIKE '%' || ? || '%') OR (key2 = ? AND key1 LIKE '%' || ? || '%')", key, params[:query], key, params[:query]) : cq.condition('key1 = ? OR key2 = ?', key, key)).
+ total = (params[:query].to_s != '' ? cq.condition("(key1 = ? AND key2 LIKE '%' || ? || '%') OR (key2 = ? AND key1 LIKE '%' || ? || '%')", key, params[:query], key, params[:query]) : cq.condition('key1 = ? OR key2 = ?', key, key)).
condition("count_#{filter_type} > 0").
get_first_value().to_i
@@ -350,7 +350,7 @@ class Taginfo < Sinatra::Base
condition('key = ?', key).
get_first_value()
- res = (params[:query] != '' ?
+ res = (params[:query].to_s != '' ?
@db.select("SELECT p.key1 AS other_key, p.count_#{filter_type} AS together_count, k.count_#{filter_type} AS other_count, CAST(p.count_#{filter_type} AS REAL) / k.count_#{filter_type} AS from_fraction FROM db.keypairs p, db.keys k WHERE p.key1=k.key AND p.key2=? AND (p.key1 LIKE '%' || ? || '%') AND p.count_#{filter_type} > 0
UNION SELECT p.key2 AS other_key, p.count_#{filter_type} AS together_count, k.count_#{filter_type} AS other_count, CAST(p.count_#{filter_type} AS REAL) / k.count_#{filter_type} AS from_fraction FROM db.keypairs p, db.keys k WHERE p.key2=k.key AND p.key1=? AND (p.key2 LIKE '%' || ? || '%') AND p.count_#{filter_type} > 0", key, params[:query], key, params[:query]) :
@db.select("SELECT p.key1 AS other_key, p.count_#{filter_type} AS together_count, k.count_#{filter_type} AS other_count, CAST(p.count_#{filter_type} AS REAL) / k.count_#{filter_type} AS from_fraction FROM db.keypairs p, db.keys k WHERE p.key1=k.key AND p.key2=? AND p.count_#{filter_type} > 0