mirror of
https://github.com/mastodon/mastodon.git
synced 2025-07-12 15:33:14 +00:00
Compare commits
2 Commits
52dad3c520
...
d6f4575213
Author | SHA1 | Date | |
---|---|---|---|
![]() |
d6f4575213 | ||
![]() |
bb89b3dc37 |
|
@ -36,7 +36,7 @@ class AnnualReport::Archetype < AnnualReport::Source
|
|||
end
|
||||
|
||||
def replies_count
|
||||
@replies_count ||= report_statuses.where.not(in_reply_to_id: nil).not_replying_to_account(@account).count
|
||||
@replies_count ||= report_statuses.only_replies.not_replying_to_account(@account).count
|
||||
end
|
||||
|
||||
def standalone_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).not_replying_to_account(@account).count,
|
||||
replies: report_statuses.only_replies.not_replying_to_account(@account).count,
|
||||
standalone: report_statuses.without_replies.without_reblogs.count,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -120,6 +120,7 @@ class Status < ApplicationRecord
|
|||
scope :with_accounts, ->(ids) { where(id: ids).includes(:account) }
|
||||
scope :without_replies, -> { not_reply.or(reply_to_account) }
|
||||
scope :not_reply, -> { where(reply: false) }
|
||||
scope :only_replies, -> { where.not(in_reply_to_id: nil) }
|
||||
scope :only_reblogs, -> { where.not(reblog_of_id: nil) }
|
||||
scope :only_polls, -> { where.not(poll_id: nil) }
|
||||
scope :without_polls, -> { where(poll_id: nil) }
|
||||
|
|
|
@ -376,6 +376,17 @@ RSpec.describe Status do
|
|||
end
|
||||
end
|
||||
|
||||
describe '.only_replies' do
|
||||
let!(:status) { Fabricate :status }
|
||||
let!(:replying_status) { Fabricate :status, thread: Fabricate(:status) }
|
||||
|
||||
it 'returns the expected statuses' do
|
||||
expect(described_class.only_replies)
|
||||
.to include(replying_status)
|
||||
.and not_include(status)
|
||||
end
|
||||
end
|
||||
|
||||
describe '.only_polls' do
|
||||
let!(:poll_status) { Fabricate :status, poll: Fabricate(:poll) }
|
||||
let!(:no_poll_status) { Fabricate :status }
|
||||
|
|
Loading…
Reference in New Issue
Block a user