mirror of
https://github.com/mastodon/mastodon.git
synced 2025-09-06 18:01:05 +00:00
Add Status.only_polls
(and without polls) scope (#35330)
This commit is contained in:
parent
a315934314
commit
4ecfbd3920
|
@ -28,7 +28,7 @@ class AnnualReport::Archetype < AnnualReport::Source
|
||||||
end
|
end
|
||||||
|
|
||||||
def polls_count
|
def polls_count
|
||||||
@polls_count ||= report_statuses.where.not(poll_id: nil).count
|
@polls_count ||= report_statuses.only_polls.count
|
||||||
end
|
end
|
||||||
|
|
||||||
def reblogs_count
|
def reblogs_count
|
||||||
|
|
|
@ -161,7 +161,7 @@ class AccountStatusesCleanupPolicy < ApplicationRecord
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_poll_scope
|
def without_poll_scope
|
||||||
Status.where(poll_id: nil)
|
Status.without_polls
|
||||||
end
|
end
|
||||||
|
|
||||||
def without_popular_scope
|
def without_popular_scope
|
||||||
|
|
|
@ -121,6 +121,8 @@ class Status < ApplicationRecord
|
||||||
scope :without_replies, -> { not_reply.or(reply_to_account) }
|
scope :without_replies, -> { not_reply.or(reply_to_account) }
|
||||||
scope :not_reply, -> { where(reply: false) }
|
scope :not_reply, -> { where(reply: false) }
|
||||||
scope :only_reblogs, -> { where.not(reblog_of_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) }
|
||||||
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 :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 }) }
|
||||||
|
|
|
@ -363,6 +363,28 @@ RSpec.describe Status do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
describe '.only_polls' do
|
||||||
|
let!(:poll_status) { Fabricate :status, poll: Fabricate(:poll) }
|
||||||
|
let!(:no_poll_status) { Fabricate :status }
|
||||||
|
|
||||||
|
it 'returns the expected statuses' do
|
||||||
|
expect(described_class.only_polls)
|
||||||
|
.to include(poll_status)
|
||||||
|
.and not_include(no_poll_status)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
describe '.without_polls' do
|
||||||
|
let!(:poll_status) { Fabricate :status, poll: Fabricate(:poll) }
|
||||||
|
let!(:no_poll_status) { Fabricate :status }
|
||||||
|
|
||||||
|
it 'returns the expected statuses' do
|
||||||
|
expect(described_class.without_polls)
|
||||||
|
.to not_include(poll_status)
|
||||||
|
.and include(no_poll_status)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
describe '.tagged_with' do
|
describe '.tagged_with' do
|
||||||
let(:tag_cats) { Fabricate(:tag, name: 'cats') }
|
let(:tag_cats) { Fabricate(:tag, name: 'cats') }
|
||||||
let(:tag_dogs) { Fabricate(:tag, name: 'dogs') }
|
let(:tag_dogs) { Fabricate(:tag, name: 'dogs') }
|
||||||
|
|
Loading…
Reference in New Issue
Block a user