about summary refs log tree commit diff
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/controllers/relationships_controller.rb19
-rw-r--r--app/helpers/admin/filter_helper.rb2
-rw-r--r--app/views/relationships/show.html.haml11
3 files changed, 22 insertions, 10 deletions
diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb
index e6dd65e44..84cb178a6 100644
--- a/app/controllers/relationships_controller.rb
+++ b/app/controllers/relationships_controller.rb
@@ -31,17 +31,18 @@ class RelationshipsController < ApplicationController
   def relationships_scope
     scope = begin
       if following_relationship?
-        current_account.following.includes(:account_stat)
+        current_account.following.joins(:account_stat)
       else
-        current_account.followers.includes(:account_stat)
+        current_account.followers.joins(:account_stat)
       end
     end
 
     scope.merge!(Follow.recent)
     scope.merge!(mutual_relationship_scope) if mutual_relationship?
-    scope.merge!(abandoned_account_scope)   if params[:status] == 'abandoned'
-    scope.merge!(active_account_scope)      if params[:status] == 'active'
+    scope.merge!(moved_account_scope)       if params[:status] == 'moved'
+    scope.merge!(primary_account_scope)     if params[:status] == 'primary'
     scope.merge!(by_domain_scope)           if params[:by_domain].present?
+    scope.merge!(dormant_account_scope)     if params[:activity] == 'dormant'
 
     scope
   end
@@ -50,14 +51,18 @@ class RelationshipsController < ApplicationController
     Account.where(id: current_account.following)
   end
 
-  def abandoned_account_scope
+  def moved_account_scope
     Account.where.not(moved_to_account_id: nil)
   end
 
-  def active_account_scope
+  def primary_account_scope
     Account.where(moved_to_account_id: nil)
   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
     Account.where(domain: params[:by_domain])
   end
@@ -79,7 +84,7 @@ class RelationshipsController < ApplicationController
   end
 
   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
 
   def action_from_button
diff --git a/app/helpers/admin/filter_helper.rb b/app/helpers/admin/filter_helper.rb
index 09a356296..4fd36ef42 100644
--- a/app/helpers/admin/filter_helper.rb
+++ b/app/helpers/admin/filter_helper.rb
@@ -7,7 +7,7 @@ module Admin::FilterHelper
   CUSTOM_EMOJI_FILTERS = %i(local remote by_domain shortcode).freeze
   TAGS_FILTERS         = %i(hidden).freeze
   INSTANCES_FILTERS    = %i(limited by_domain).freeze
-  FOLLOWERS_FILTERS    = %i(relationship status by_domain).freeze
+  FOLLOWERS_FILTERS    = %i(relationship status by_domain activity).freeze
 
   FILTERS = ACCOUNT_FILTERS + REPORT_FILTERS + INVITE_FILTER + CUSTOM_EMOJI_FILTERS + TAGS_FILTERS + INSTANCES_FILTERS + FOLLOWERS_FILTERS
 
diff --git a/app/views/relationships/show.html.haml b/app/views/relationships/show.html.haml
index 33a43f1a8..63745119a 100644
--- a/app/views/relationships/show.html.haml
+++ b/app/views/relationships/show.html.haml
@@ -16,13 +16,20 @@
     %strong= t 'relationships.status'
     %ul
       %li= filter_link_to t('generic.all'), status: nil
-      %li= filter_link_to t('relationships.active'), status: 'active'
-      %li= filter_link_to t('relationships.abandoned'), status: 'abandoned'
+      %li= filter_link_to t('relationships.primary'), status: 'primary'
+      %li= filter_link_to t('relationships.moved'), status: 'moved'
+
+  .filter-subset
+    %strong= t 'relationships.activity'
+    %ul
+      %li= filter_link_to t('generic.all'), activity: nil
+      %li= filter_link_to t('relationships.dormant'), activity: 'dormant'
 
 = form_for(@form, url: relationships_path, method: :patch) do |f|
   = hidden_field_tag :page, params[:page] || 1
   = hidden_field_tag :relationship, params[:relationship]
   = hidden_field_tag :status, params[:status]
+  = hidden_field_tag :activity, params[:activity]
 
   .batch-table
     .batch-table__toolbar