mirror of
https://github.com/mastodon/mastodon.git
synced 2024-11-20 03:25:17 +01:00
Use Announcement scopes in scheduled status scheduler
This commit is contained in:
parent
cfb8fc6222
commit
409a29befd
@ -22,6 +22,10 @@ class Announcement < ApplicationRecord
|
||||
scope :published, -> { where(published: true) }
|
||||
scope :chronological, -> { order(coalesced_chronology_timestamps.asc) }
|
||||
scope :reverse_chronological, -> { order(coalesced_chronology_timestamps.desc) }
|
||||
scope :ending_before, ->(date) { ending.where(ends_at: ..date) }
|
||||
scope :ending, -> { where.not(ends_at: nil) }
|
||||
scope :scheduled_before, ->(date) { scheduled.where(scheduled_at: ..date) }
|
||||
scope :scheduled, -> { where.not(scheduled_at: nil) }
|
||||
|
||||
has_many :announcement_mutes, dependent: :destroy
|
||||
has_many :announcement_reactions, dependent: :destroy
|
||||
|
@ -30,7 +30,7 @@ class Scheduler::ScheduledStatusesScheduler
|
||||
end
|
||||
|
||||
def due_announcements
|
||||
Announcement.unpublished.where('scheduled_at IS NOT NULL AND scheduled_at <= ?', Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET)
|
||||
Announcement.unpublished.scheduled_before(publication_scheduled_at)
|
||||
end
|
||||
|
||||
def unpublish_expired_announcements!
|
||||
@ -38,6 +38,10 @@ class Scheduler::ScheduledStatusesScheduler
|
||||
end
|
||||
|
||||
def expired_announcements
|
||||
Announcement.published.where('ends_at IS NOT NULL AND ends_at <= ?', Time.now.utc)
|
||||
Announcement.published.ending_before(Time.now.utc)
|
||||
end
|
||||
|
||||
def publication_scheduled_at
|
||||
Time.now.utc + PostStatusService::MIN_SCHEDULE_OFFSET
|
||||
end
|
||||
end
|
||||
|
Loading…
Reference in New Issue
Block a user