|
|
@ -31,17 +31,18 @@ class RelationshipsController < ApplicationController
|
|
|
|
def relationships_scope
|
|
|
|
def relationships_scope
|
|
|
|
scope = begin
|
|
|
|
scope = begin
|
|
|
|
if following_relationship?
|
|
|
|
if following_relationship?
|
|
|
|
current_account.following.includes(:account_stat)
|
|
|
|
current_account.following.joins(:account_stat)
|
|
|
|
else
|
|
|
|
else
|
|
|
|
current_account.followers.includes(:account_stat)
|
|
|
|
current_account.followers.joins(:account_stat)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
scope.merge!(Follow.recent)
|
|
|
|
scope.merge!(Follow.recent)
|
|
|
|
scope.merge!(mutual_relationship_scope) if mutual_relationship?
|
|
|
|
scope.merge!(mutual_relationship_scope) if mutual_relationship?
|
|
|
|
scope.merge!(abandoned_account_scope) if params[:status] == 'abandoned'
|
|
|
|
scope.merge!(moved_account_scope) if params[:status] == 'moved'
|
|
|
|
scope.merge!(active_account_scope) if params[:status] == 'active'
|
|
|
|
scope.merge!(primary_account_scope) if params[:status] == 'primary'
|
|
|
|
scope.merge!(by_domain_scope) if params[:by_domain].present?
|
|
|
|
scope.merge!(by_domain_scope) if params[:by_domain].present?
|
|
|
|
|
|
|
|
scope.merge!(dormant_account_scope) if params[:activity] == 'dormant'
|
|
|
|
|
|
|
|
|
|
|
|
scope
|
|
|
|
scope
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -50,14 +51,18 @@ class RelationshipsController < ApplicationController
|
|
|
|
Account.where(id: current_account.following)
|
|
|
|
Account.where(id: current_account.following)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def abandoned_account_scope
|
|
|
|
def moved_account_scope
|
|
|
|
Account.where.not(moved_to_account_id: nil)
|
|
|
|
Account.where.not(moved_to_account_id: nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def active_account_scope
|
|
|
|
def primary_account_scope
|
|
|
|
Account.where(moved_to_account_id: nil)
|
|
|
|
Account.where(moved_to_account_id: nil)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def dormant_account_scope
|
|
|
|
|
|
|
|
AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago)))
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def by_domain_scope
|
|
|
|
def by_domain_scope
|
|
|
|
Account.where(domain: params[:by_domain])
|
|
|
|
Account.where(domain: params[:by_domain])
|
|
|
|
end
|
|
|
|
end
|
|
|
@ -79,7 +84,7 @@ class RelationshipsController < ApplicationController
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def current_params
|
|
|
|
def current_params
|
|
|
|
params.slice(:page, :status, :relationship, :by_domain).permit(:page, :status, :relationship, :by_domain)
|
|
|
|
params.slice(:page, :status, :relationship, :by_domain, :activity).permit(:page, :status, :relationship, :by_domain, :activity)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def action_from_button
|
|
|
|
def action_from_button
|
|
|
|