Introduce recent to Follow (#3247)
Introduce recent to Follow, as Account and other models have. This change also adds specs for the scope and the dependents.
This commit is contained in:
committed by
Eugen Rochko
parent
860ffc0560
commit
bf575a1f5e
@ -4,6 +4,6 @@ class FollowerAccountsController < ApplicationController
|
||||
include AccountControllerConcern
|
||||
|
||||
def index
|
||||
@follows = Follow.where(target_account: @account).order(id: :desc).page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
||||
@follows = Follow.where(target_account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:account)
|
||||
end
|
||||
end
|
||||
|
@ -4,6 +4,6 @@ class FollowingAccountsController < ApplicationController
|
||||
include AccountControllerConcern
|
||||
|
||||
def index
|
||||
@follows = Follow.where(account: @account).order(id: :desc).page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
||||
@follows = Follow.where(account: @account).recent.page(params[:page]).per(FOLLOW_PER_PAGE).preload(:target_account)
|
||||
end
|
||||
end
|
||||
|
@ -23,4 +23,6 @@ class Follow < ApplicationRecord
|
||||
has_one :notification, as: :activity, dependent: :destroy
|
||||
|
||||
validates :account_id, uniqueness: { scope: :target_account_id }
|
||||
|
||||
scope :recent, -> { reorder(id: :desc) }
|
||||
end
|
||||
|
Reference in New Issue
Block a user