mirror of
https://github.com/discourse/discourse.git
synced 2026-08-06 06:24:48 +08:00
Since we have been using the upcoming change system
more heavily, we noticed that notifications for available changes
(i.e. changes that have been added at promotion status - 1 OR
changes that recently reached promotion status - 1) are crowding
the admin's notifications a lot.
To address this, we already allowed admins to opt out of these
in 0c46a2e805 . However, we also
want to reduce the cadence of these notifications for admins who do want
to opt out completely.
This commit changes upcoming change available notifications to be
collected & sent in a weekly job, rather than in the job that runs
every 20 minutes & logs added/status changed events.
This weekly job will also handle consolidating existing unread upcoming
change available notifications, and making sure that we do not send
N new notifications per change when an admin has no existing unread
notification.
Upcoming change promoted notifications will still happen "instantly"
34 lines
1 KiB
Ruby
Vendored
34 lines
1 KiB
Ruby
Vendored
# frozen_string_literal: true
|
|
|
|
# Handles tracking the addition, removal, and status changes of upcoming changes,
|
|
# via UpcomingChangeEvent records, and subsequently notifying admins that the
|
|
# upcoming change is available for them to opt-in to, based on certain criteria
|
|
# that are explained in the Action classes.
|
|
#
|
|
# Called from the Jobs::Scheduled::CheckUpcomingChanges job.
|
|
class UpcomingChanges::Track
|
|
include Service::Base
|
|
|
|
model :all_admins
|
|
model :added_changes, optional: true
|
|
model :removed_changes, optional: true
|
|
model :status_changes, optional: true
|
|
|
|
private
|
|
|
|
def fetch_all_admins
|
|
User.human_users.admins
|
|
end
|
|
|
|
def fetch_added_changes(all_admins:)
|
|
UpcomingChanges::Action::TrackAddedChanges.call(all_admins:)
|
|
end
|
|
|
|
def fetch_removed_changes
|
|
UpcomingChanges::Action::TrackRemovedChanges.call
|
|
end
|
|
|
|
def fetch_status_changes(added_changes:, removed_changes:, all_admins:)
|
|
UpcomingChanges::Action::TrackStatusChanges.call(all_admins:, added_changes:, removed_changes:)
|
|
end
|
|
end
|