about summary refs log tree commit diff
path: root/app/controllers/relationships_controller.rb
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-03-18 18:03:27 +0100
committerThibaut Girka <thib@sitedethib.com>2019-03-18 18:03:27 +0100
commit291012ec0c08f5323b2102eb4d2dc8714ddce4d9 (patch)
tree09e7a5fef106da1b6ebdc53ac0df62cafc159520 /app/controllers/relationships_controller.rb
parent6e3a4bcbc70bb33bfb0746cf3b2186ee9f4e6515 (diff)
parentf85b66eb8cc9513822d0ece3928b12aa789bb410 (diff)
Merge branch 'master' into glitch-soc/merge-upstream
Conflicts:
- app/controllers/accounts_controller.rb
- app/controllers/follower_accounts_controller.rb
- app/controllers/statuses_controller.rb

All conflicts caused by the additional `use_pack` used for glitch-soc's theming
system.
Diffstat (limited to 'app/controllers/relationships_controller.rb')
-rw-r--r--app/controllers/relationships_controller.rb19
1 files changed, 12 insertions, 7 deletions
diff --git a/app/controllers/relationships_controller.rb b/app/controllers/relationships_controller.rb
index af91cb658..a0b9c77df 100644
--- a/app/controllers/relationships_controller.rb
+++ b/app/controllers/relationships_controller.rb
@@ -32,17 +32,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
@@ -51,14 +52,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
@@ -80,7 +85,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