diff options
Diffstat (limited to 'app/models')
-rw-r--r-- | app/models/account.rb | 12 | ||||
-rw-r--r-- | app/models/tag.rb | 4 |
2 files changed, 8 insertions, 8 deletions
diff --git a/app/models/account.rb b/app/models/account.rb index cbba8b5b6..c59c76009 100644 --- a/app/models/account.rb +++ b/app/models/account.rb @@ -203,7 +203,7 @@ class Account < ApplicationRecord end def triadic_closures(account, limit = 5) - sql = <<SQL + sql = <<-SQL.squish WITH first_degree AS ( SELECT target_account_id FROM follows @@ -216,7 +216,7 @@ class Account < ApplicationRecord GROUP BY target_account_id, accounts.id ORDER BY count(account_id) DESC LIMIT ? -SQL + SQL Account.find_by_sql([sql, account.id, account.id, limit]) end @@ -226,7 +226,7 @@ SQL textsearch = '(setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\'))' query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')' - sql = <<SQL + sql = <<-SQL.squish SELECT accounts.*, ts_rank_cd(#{textsearch}, #{query}, 32) AS rank @@ -234,7 +234,7 @@ SQL WHERE #{query} @@ #{textsearch} ORDER BY rank DESC LIMIT ? -SQL + SQL Account.find_by_sql([sql, limit]) end @@ -244,7 +244,7 @@ SQL textsearch = '(setweight(to_tsvector(\'simple\', accounts.display_name), \'A\') || setweight(to_tsvector(\'simple\', accounts.username), \'B\') || setweight(to_tsvector(\'simple\', coalesce(accounts.domain, \'\')), \'C\'))' query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')' - sql = <<SQL + sql = <<-SQL.squish SELECT accounts.*, (count(f.id) + 1) * ts_rank_cd(#{textsearch}, #{query}, 32) AS rank @@ -254,7 +254,7 @@ SQL GROUP BY accounts.id ORDER BY rank DESC LIMIT ? -SQL + SQL Account.find_by_sql([sql, account.id, account.id, limit]) end diff --git a/app/models/tag.rb b/app/models/tag.rb index 15625ca43..6209d7dab 100644 --- a/app/models/tag.rb +++ b/app/models/tag.rb @@ -17,7 +17,7 @@ class Tag < ApplicationRecord textsearch = 'to_tsvector(\'simple\', tags.name)' query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')' - sql = <<SQL + sql = <<-SQL.squish SELECT tags.*, ts_rank_cd(#{textsearch}, #{query}) AS rank @@ -25,7 +25,7 @@ class Tag < ApplicationRecord WHERE #{query} @@ #{textsearch} ORDER BY rank DESC LIMIT ? -SQL + SQL Tag.find_by_sql([sql, limit]) end |