@ -203,7 +203,7 @@ class Account < ApplicationRecord
end
end
def triadic_closures ( account , limit = 5 )
def triadic_closures ( account , limit = 5 )
sql = << SQL
sql = << - SQL . squish
WITH first_degree AS (
WITH first_degree AS (
SELECT target_account_id
SELECT target_account_id
FROM follows
FROM follows
@ -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\'))'
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 + ' || \' \'\'\' || \':*\')'
query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')'
sql = << SQL
sql = << - SQL . squish
SELECT
SELECT
accounts . * ,
accounts . * ,
ts_rank_cd ( #{textsearch}, #{query}, 32) AS rank
ts_rank_cd ( #{textsearch}, #{query}, 32) AS rank
@ -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\'))'
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 + ' || \' \'\'\' || \':*\')'
query = 'to_tsquery(\'simple\', \'\'\' \' || ' + terms + ' || \' \'\'\' || \':*\')'
sql = << SQL
sql = << - SQL . squish
SELECT
SELECT
accounts . * ,
accounts . * ,
( count ( f . id ) + 1 ) * ts_rank_cd ( #{textsearch}, #{query}, 32) AS rank
( count ( f . id ) + 1 ) * ts_rank_cd ( #{textsearch}, #{query}, 32) AS rank