Add circle editor
This commit is contained in:
parent
c97e63bb18
commit
b0854b1dd8
33 changed files with 1671 additions and 31 deletions
|
@ -44,13 +44,15 @@ class AccountSearchService < BaseService
|
|||
def must_clauses
|
||||
if @account && @options[:following]
|
||||
[core_query, only_following_query]
|
||||
elsif @account && @options[:follower]
|
||||
[core_query, only_follower_query]
|
||||
else
|
||||
[core_query]
|
||||
end
|
||||
end
|
||||
|
||||
def should_clauses
|
||||
if @account && !@options[:following]
|
||||
if @account && !@options[:following] && !@options[:follower]
|
||||
[boost_following_query]
|
||||
else
|
||||
[]
|
||||
|
@ -76,6 +78,23 @@ class AccountSearchService < BaseService
|
|||
}
|
||||
end
|
||||
|
||||
def only_follower_query
|
||||
{
|
||||
terms: {
|
||||
id: follower_ids,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
def boost_follower_query
|
||||
{
|
||||
terms: {
|
||||
id: follower_ids,
|
||||
boost: 100,
|
||||
},
|
||||
}
|
||||
end
|
||||
|
||||
# This function deranks accounts that follow more people than follow them
|
||||
def reputation_score_function
|
||||
{
|
||||
|
@ -114,6 +133,10 @@ class AccountSearchService < BaseService
|
|||
def following_ids
|
||||
@following_ids ||= @account.active_relationships.pluck(:target_account_id) + [@account.id]
|
||||
end
|
||||
|
||||
def follower_ids
|
||||
@follower_ids ||= @account.passive_relationships.pluck(:account_id)
|
||||
end
|
||||
end
|
||||
|
||||
class AutocompleteQueryBuilder < QueryBuilder
|
||||
|
@ -177,6 +200,7 @@ class AccountSearchService < BaseService
|
|||
end
|
||||
|
||||
match = nil if !match.nil? && !account.nil? && options[:following] && !account.following?(match)
|
||||
match = nil if !match.nil? && !account.nil? && options[:follower] && !match.following?(account)
|
||||
|
||||
@exact_match = match
|
||||
end
|
||||
|
@ -200,7 +224,7 @@ class AccountSearchService < BaseService
|
|||
end
|
||||
|
||||
def advanced_search_results
|
||||
Account.advanced_search_for(terms_for_query, account, limit: limit_for_non_exact_results, following: options[:following], offset: offset)
|
||||
Account.advanced_search_for(terms_for_query, account, limit: limit_for_non_exact_results, following: options[:following], follower: options[:follower], offset: offset)
|
||||
end
|
||||
|
||||
def simple_search_results
|
||||
|
@ -210,9 +234,9 @@ class AccountSearchService < BaseService
|
|||
def from_elasticsearch
|
||||
query_builder = begin
|
||||
if options[:use_searchable_text]
|
||||
FullQueryBuilder.new(terms_for_query, account, options.slice(:following))
|
||||
FullQueryBuilder.new(terms_for_query, account, options.slice(:following, :follower))
|
||||
else
|
||||
AutocompleteQueryBuilder.new(terms_for_query, account, options.slice(:following))
|
||||
AutocompleteQueryBuilder.new(terms_for_query, account, options.slice(:following, :follower))
|
||||
end
|
||||
end
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue