Aggiunge sulla dashboard invii il KPI mail/ora dagli invii SMTP confermati.
CI / scan_js (push) Has been cancelled
CI / lint (push) Has been cancelled
CI / scan_ruby (push) Has been cancelled

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-09-07 12:43:39 +02:00
co-authored by Cursor
parent 3c8bfe053f
commit 390cb0e657
5 changed files with 132 additions and 1 deletions
@@ -0,0 +1,35 @@
class Mailings::HourlyThroughput
HOUR = 1.hour
RECENT = 15.minutes
def initialize(project, now: Time.current)
@project = project
@now = now
end
def sent
@sent ||= sent_since(HOUR)
end
def recent_sent
@recent_sent ||= sent_since(RECENT)
end
def failed
@failed ||= recipients.failed.where(updated_at: (@now - HOUR)..@now).count
end
def drained
sent + failed
end
private
def sent_since(window)
recipients.sent.where(sent_at: (@now - window)..@now).count
end
def recipients
MailingRecipient.joins(:mailing).merge(Mailing.for_project(@project))
end
end