Add interrelationship filter
This commit is contained in:
parent
5ea43e505b
commit
c59ca999a6
6 changed files with 44 additions and 4 deletions
|
@ -42,7 +42,11 @@ class RelationshipsController < ApplicationController
|
||||||
end
|
end
|
||||||
|
|
||||||
def mutual_relationship?
|
def mutual_relationship?
|
||||||
params[:relationship] == 'mutual'
|
params[:interrelationship] == 'mutual'
|
||||||
|
end
|
||||||
|
|
||||||
|
def one_way_relationship?
|
||||||
|
params[:interrelationship] == 'one_way'
|
||||||
end
|
end
|
||||||
|
|
||||||
def followed_by_relationship?
|
def followed_by_relationship?
|
||||||
|
|
|
@ -385,6 +385,7 @@ body,
|
||||||
.filters {
|
.filters {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-wrap: wrap;
|
flex-wrap: wrap;
|
||||||
|
margin-right: -40px;
|
||||||
|
|
||||||
.filter-subset {
|
.filter-subset {
|
||||||
flex: 0 0 auto;
|
flex: 0 0 auto;
|
||||||
|
|
|
@ -346,6 +346,11 @@ body.rtl {
|
||||||
text-align: right;
|
text-align: right;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.filter {
|
||||||
|
margin-right: 0;
|
||||||
|
margin-left: -45px;
|
||||||
|
}
|
||||||
|
|
||||||
.filters .filter-subset {
|
.filters .filter-subset {
|
||||||
margin-right: 0;
|
margin-right: 0;
|
||||||
margin-left: 45px;
|
margin-left: 45px;
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
class RelationshipFilter
|
class RelationshipFilter
|
||||||
KEYS = %i(
|
KEYS = %i(
|
||||||
relationship
|
relationship
|
||||||
|
interrelationship
|
||||||
status
|
status
|
||||||
by_domain
|
by_domain
|
||||||
activity
|
activity
|
||||||
|
@ -42,6 +43,8 @@ class RelationshipFilter
|
||||||
case key
|
case key
|
||||||
when 'relationship'
|
when 'relationship'
|
||||||
relationship_scope(value)
|
relationship_scope(value)
|
||||||
|
when 'interrelationship'
|
||||||
|
by_interrelationship_scope(value)
|
||||||
when 'by_domain'
|
when 'by_domain'
|
||||||
by_domain_scope(value)
|
by_domain_scope(value)
|
||||||
when 'location'
|
when 'location'
|
||||||
|
@ -63,8 +66,6 @@ class RelationshipFilter
|
||||||
account.following.eager_load(:account_stat).reorder(nil)
|
account.following.eager_load(:account_stat).reorder(nil)
|
||||||
when 'followed_by'
|
when 'followed_by'
|
||||||
account.followers.eager_load(:account_stat).reorder(nil)
|
account.followers.eager_load(:account_stat).reorder(nil)
|
||||||
when 'mutual'
|
|
||||||
account.followers.eager_load(:account_stat).reorder(nil).merge(Account.where(id: account.following))
|
|
||||||
when 'invited'
|
when 'invited'
|
||||||
Account.joins(user: :invite).merge(Invite.where(user: account.user)).eager_load(:account_stat).reorder(nil)
|
Account.joins(user: :invite).merge(Invite.where(user: account.user)).eager_load(:account_stat).reorder(nil)
|
||||||
else
|
else
|
||||||
|
@ -72,6 +73,27 @@ class RelationshipFilter
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def by_interrelationship_scope(value)
|
||||||
|
case value
|
||||||
|
when 'mutual'
|
||||||
|
case params[:relationship]
|
||||||
|
when 'following'
|
||||||
|
Account.where(id: account.followers)
|
||||||
|
when 'followed_by'
|
||||||
|
Account.where(id: account.following)
|
||||||
|
end
|
||||||
|
when 'one_way'
|
||||||
|
case params[:relationship]
|
||||||
|
when 'following'
|
||||||
|
Account.where.not(id: account.followers)
|
||||||
|
when 'followed_by'
|
||||||
|
Account.where.not(id: account.following)
|
||||||
|
end
|
||||||
|
else
|
||||||
|
raise "Unknown interrelationship: #{value}"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
def by_domain_scope(value)
|
def by_domain_scope(value)
|
||||||
Account.where(domain: value)
|
Account.where(domain: value)
|
||||||
end
|
end
|
||||||
|
|
|
@ -10,7 +10,13 @@
|
||||||
%ul
|
%ul
|
||||||
%li= filter_link_to t('relationships.following'), relationship: nil
|
%li= filter_link_to t('relationships.following'), relationship: nil
|
||||||
%li= filter_link_to t('relationships.followers'), relationship: 'followed_by'
|
%li= filter_link_to t('relationships.followers'), relationship: 'followed_by'
|
||||||
%li= filter_link_to t('relationships.mutual'), relationship: 'mutual'
|
|
||||||
|
.filter-subset
|
||||||
|
%strong= t 'relationships.interrelationship'
|
||||||
|
%ul
|
||||||
|
%li= filter_link_to t('generic.all'), interrelationship: nil
|
||||||
|
%li= filter_link_to t('relationships.mutual'), interrelationship: 'mutual'
|
||||||
|
%li= filter_link_to t('relationships.one_way'), interrelationship: 'one_way'
|
||||||
|
|
||||||
.filter-subset
|
.filter-subset
|
||||||
%strong= t 'relationships.status'
|
%strong= t 'relationships.status'
|
||||||
|
|
|
@ -1236,11 +1236,13 @@ en:
|
||||||
follow_selected_followers: Follow selected followers
|
follow_selected_followers: Follow selected followers
|
||||||
followers: Followers
|
followers: Followers
|
||||||
following: Following
|
following: Following
|
||||||
|
interrelationship: Interrelationship
|
||||||
invited: Invited
|
invited: Invited
|
||||||
last_active: Last active
|
last_active: Last active
|
||||||
most_recent: Most recent
|
most_recent: Most recent
|
||||||
moved: Moved
|
moved: Moved
|
||||||
mutual: Mutual
|
mutual: Mutual
|
||||||
|
one_way: One-way
|
||||||
primary: Primary
|
primary: Primary
|
||||||
relationship: Relationship
|
relationship: Relationship
|
||||||
remove_selected_domains: Remove all followers from the selected domains
|
remove_selected_domains: Remove all followers from the selected domains
|
||||||
|
|
Loading…
Reference in a new issue