Skip to content

Commit 40faa91

Browse files
authored
Add dormant filter to relationship manager, rename other filters (mastodon#10308)
Rename "abandoned" to "moved", and "active" to "primary"
1 parent 3872872 commit 40faa91

4 files changed

Lines changed: 26 additions & 12 deletions

File tree

app/controllers/relationships_controller.rb

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -31,17 +31,18 @@ def set_accounts
3131
def relationships_scope
3232
scope = begin
3333
if following_relationship?
34-
current_account.following.includes(:account_stat)
34+
current_account.following.joins(:account_stat)
3535
else
36-
current_account.followers.includes(:account_stat)
36+
current_account.followers.joins(:account_stat)
3737
end
3838
end
3939

4040
scope.merge!(Follow.recent)
4141
scope.merge!(mutual_relationship_scope) if mutual_relationship?
42-
scope.merge!(abandoned_account_scope) if params[:status] == 'abandoned'
43-
scope.merge!(active_account_scope) if params[:status] == 'active'
42+
scope.merge!(moved_account_scope) if params[:status] == 'moved'
43+
scope.merge!(primary_account_scope) if params[:status] == 'primary'
4444
scope.merge!(by_domain_scope) if params[:by_domain].present?
45+
scope.merge!(dormant_account_scope) if params[:activity] == 'dormant'
4546

4647
scope
4748
end
@@ -50,14 +51,18 @@ def mutual_relationship_scope
5051
Account.where(id: current_account.following)
5152
end
5253

53-
def abandoned_account_scope
54+
def moved_account_scope
5455
Account.where.not(moved_to_account_id: nil)
5556
end
5657

57-
def active_account_scope
58+
def primary_account_scope
5859
Account.where(moved_to_account_id: nil)
5960
end
6061

62+
def dormant_account_scope
63+
AccountStat.where(last_status_at: nil).or(AccountStat.where(AccountStat.arel_table[:last_status_at].lt(1.month.ago)))
64+
end
65+
6166
def by_domain_scope
6267
Account.where(domain: params[:by_domain])
6368
end
@@ -79,7 +84,7 @@ def followed_by_relationship?
7984
end
8085

8186
def current_params
82-
params.slice(:page, :status, :relationship, :by_domain).permit(:page, :status, :relationship, :by_domain)
87+
params.slice(:page, :status, :relationship, :by_domain, :activity).permit(:page, :status, :relationship, :by_domain, :activity)
8388
end
8489

8590
def action_from_button

app/helpers/admin/filter_helper.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ module Admin::FilterHelper
77
CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
88
TAGS_FILTERS = %i(hidden).freeze
99
INSTANCES_FILTERS = %i(limited by_domain).freeze
10-
FOLLOWERS_FILTERS = %i(relationship status by_domain).freeze
10+
FOLLOWERS_FILTERS = %i(relationship status by_domain activity).freeze
1111

1212
FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS
1313

app/views/relationships/show.html.haml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,20 @@
1616
%strong= t 'relationships.status'
1717
%ul
1818
%li= filter_link_to t('generic.all'), status: nil
19-
%li= filter_link_to t('relationships.active'), status: 'active'
20-
%li= filter_link_to t('relationships.abandoned'), status: 'abandoned'
19+
%li= filter_link_to t('relationships.primary'), status: 'primary'
20+
%li= filter_link_to t('relationships.moved'), status: 'moved'
21+
22+
.filter-subset
23+
%strong= t 'relationships.activity'
24+
%ul
25+
%li= filter_link_to t('generic.all'), activity: nil
26+
%li= filter_link_to t('relationships.dormant'), activity: 'dormant'
2127

2228
= form_for(@form, url: relationships_path, method: :patch) do |f|
2329
= hidden_field_tag :page, params[:page] || 1
2430
= hidden_field_tag :relationship, params[:relationship]
2531
= hidden_field_tag :status, params[:status]
32+
= hidden_field_tag :activity, params[:activity]
2633

2734
.batch-table
2835
.batch-table__toolbar

config/locales/en.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -751,9 +751,11 @@ en:
751751
publishing: Publishing
752752
web: Web
753753
relationships:
754-
abandoned: Abandoned
755-
active: Active
754+
activity: Account activity
755+
dormant: Dormant
756+
moved: Moved
756757
mutual: Mutual
758+
primary: Primary
757759
relationship: Relationship
758760
remove_selected_domains: Remove all followers from the selected domains
759761
remove_selected_followers: Remove selected followers

0 commit comments

Comments
 (0)