mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-15 00:38:15 +00:00
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
|
||||
|
||||
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
|
||||
|
||||
def standalone_count
|
||||
|
|
|
@ -18,7 +18,7 @@ class AnnualReport::CommonlyInteractedWithAccounts < AnnualReport::Source
|
|||
private
|
||||
|
||||
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
|
||||
|
||||
def minimum_interaction_count
|
||||
|
|
|
@ -6,7 +6,7 @@ class AnnualReport::TypeDistribution < AnnualReport::Source
|
|||
type_distribution: {
|
||||
total: report_statuses.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,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -124,6 +124,7 @@ class Status < ApplicationRecord
|
|||
scope :only_polls, -> { where.not(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 :not_replying_to_account, ->(account) { where.not(in_reply_to_account: account) }
|
||||
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 :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
|
||||
|
||||
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
|
||||
before do
|
||||
alice.update(domain: 'example.com')
|
||||
|
|
Loading…
Reference in New Issue
Block a user