mirror of
https://github.com/discourse/discourse.git
synced 2024-12-02 03:23:43 +08:00
cc18a99105
Add new notification for admin problems to replace old PM-based flow.
37 lines
911 B
Ruby
37 lines
911 B
Ruby
# frozen_string_literal: true
|
|
|
|
module Jobs
|
|
class AdminProblems < ::Jobs::Scheduled
|
|
every 30.minutes
|
|
|
|
def execute(args)
|
|
Notification
|
|
.where(notification_type: Notification.types[:admin_problems])
|
|
.where("created_at < ?", 7.days.ago)
|
|
.destroy_all
|
|
|
|
return if !persistent_problems?
|
|
|
|
notified_user_ids =
|
|
Notification.where(notification_type: Notification.types[:admin_problems]).pluck(:user_id)
|
|
|
|
users = Group[:admins].users.where.not(id: notified_user_ids)
|
|
|
|
users.each do |user|
|
|
Notification.create!(
|
|
notification_type: Notification.types[:admin_problems],
|
|
user_id: user.id,
|
|
data: "{}",
|
|
)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def persistent_problems?
|
|
problems_started_at = AdminDashboardData.problems_started_at
|
|
problems_started_at && problems_started_at < 2.days.ago
|
|
end
|
|
end
|
|
end
|