Add Status#not_replying_to_account scope for annual report classes (#35257)
This commit is contained in:
parent
dd3d958e75
commit
1496488771
@ -36,7 +36,7 @@ class AnnualReport::Archetype < AnnualReport::Source
|
|||||||
end
|
end
|
||||||
|
|
||||||
def replies_count
|
def replies_count
|
||||||
@replies_count ||= report_statuses.where.not(in_reply_to_id: nil).where.not(in_reply_to_account_id: @account.id).count
|
@replies_count ||= report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def standalone_count
|
def standalone_count
|
||||||
|
|||||||
@ -18,7 +18,7 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
|||||||
private
|
private
|
||||||
|
|
||||||
def commonly_interacted_with_accounts
|
def commonly_interacted_with_accounts
|
||||||
report_statuses.where.not(in_reply_to_account_id: @account.id).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
|
report_statuses.not_replying_to_account(@account).group(:in_reply_to_account_id).having(minimum_interaction_count).order(count_all: :desc).limit(SET_SIZE).count
|
||||||
end
|
end
|
||||||
|
|
||||||
def minimum_interaction_count
|
def minimum_interaction_count
|
||||||
|
|||||||
@ -6,7 +6,7 @@ class AnnualReport::TypeDistribution < AnnualReport::Source
|
|||||||
type_distribution: {
|
type_distribution: {
|
||||||
total: report_statuses.count,
|
total: report_statuses.count,
|
||||||
reblogs: report_statuses.only_reblogs.count,
|
reblogs: report_statuses.only_reblogs.count,
|
||||||
replies: report_statuses.where.not(in_reply_to_id: nil).where.not(in_reply_to_account_id: @account.id).count,
|
replies: report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count,
|
||||||
standalone: report_statuses.without_replies.without_reblogs.count,
|
standalone: report_statuses.without_replies.without_reblogs.count,
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@ -124,6 +124,7 @@ class Status < ApplicationRecord
|
|||||||
scope :only_polls, -> { where.not(poll_id: nil) }
|
scope :only_polls, -> { where.not(poll_id: nil) }
|
||||||
scope :without_polls, -> { where(poll_id: nil) }
|
scope :without_polls, -> { where(poll_id: nil) }
|
||||||
scope :reply_to_account, -> { where(arel_table[:in_reply_to_account_id].eq arel_table[:account_id]) }
|
scope :reply_to_account, -> { where(arel_table[:in_reply_to_account_id].eq arel_table[:account_id]) }
|
||||||
|
scope :not_replying_to_account, ->(account) { where.not(in_reply_to_account: account) }
|
||||||
scope :without_reblogs, -> { where(statuses: { reblog_of_id: nil }) }
|
scope :without_reblogs, -> { where(statuses: { reblog_of_id: nil }) }
|
||||||
scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
|
scope :tagged_with, ->(tag_ids) { joins(:statuses_tags).where(statuses_tags: { tag_id: tag_ids }) }
|
||||||
scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }
|
scope :not_excluded_by_account, ->(account) { where.not(account_id: account.excluded_from_timeline_account_ids) }
|
||||||
|
|||||||
@ -191,6 +191,19 @@ RSpec.describe Status do
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.not_replying_to_account' do
|
||||||
|
let(:account) { Fabricate :account }
|
||||||
|
let!(:status_from_account) { Fabricate :status, account: account }
|
||||||
|
let!(:reply_to_account_status) { Fabricate :status, thread: status_from_account }
|
||||||
|
let!(:reply_to_other) { Fabricate :status, thread: Fabricate(:status) }
|
||||||
|
|
||||||
|
it 'returns records not in reply to provided account' do
|
||||||
|
expect(described_class.not_replying_to_account(account))
|
||||||
|
.to not_include(reply_to_account_status)
|
||||||
|
.and include(reply_to_other)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '#untrusted_favourites_count' do
|
describe '#untrusted_favourites_count' do
|
||||||
before do
|
before do
|
||||||
alice.update(domain: 'example.com')
|
alice.update(domain: 'example.com')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user