about summary refs log tree commit diff
path: root/app/lib
diff options
context:
space:
mode:
authormultiple creatures <dev@multiple-creature.party>2019-11-16 06:04:31 -0600
committermultiple creatures <dev@multiple-creature.party>2019-11-16 06:04:31 -0600
commit9de5952f4e92528a1dd664c188d730229493b707 (patch)
tree22f087d4bc6946f367248e537e55300c71697568 /app/lib
parent3b1aed6cf1776e6d2f351a6390ec6a36118ee629 (diff)
Update database queries to reflect change of search implementation.
Diffstat (limited to 'app/lib')
-rw-r--r--app/lib/bangtags.rb10
1 files changed, 2 insertions, 8 deletions
diff --git a/app/lib/bangtags.rb b/app/lib/bangtags.rb
index 37a95ae42..681fa4abc 100644
--- a/app/lib/bangtags.rb
+++ b/app/lib/bangtags.rb
@@ -716,21 +716,15 @@ class Bangtags
           @status.content_type = 'text/html'
           barchars = " #{(0x2588..0x258F).to_a.reverse.pack('U*')}"
           q = cmd[1..-1].join.strip
-          if q.start_with?('@@')
-            sql = 'tsv @@ to_tsquery(?)'
-            q = q[2..-1].lstrip
-          else
-            sql = 'tsv @@ plainto_tsquery(?)'
-          end
           next if q.blank?
           begin
-            data = @account.statuses.where(sql, q)
+            data = @account.statuses.where('text ILIKE ?', "%#{sanitize_sql_like(q)}%")
               .reorder(:created_at)
               .pluck(:created_at)
               .map { |d| d.strftime('%Y-%m') }
               .reduce(Hash.new(0)) { |h, v| h.store(v, h[v] + 1); h }
           rescue ActiveRecord::StatementInvalid
-            raise Mastodon::ValidationError, 'Your advanced search query has invalid syntax.'
+            raise Mastodon::ValidationError, 'Invalid query.'
           end
           highest = data.values.max
           avg = "<code>average: #{data.values.sum / data.count}</code>"