Aggiunge sulla dashboard invii il KPI mail/ora dagli invii SMTP confermati.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,6 +16,7 @@ class MailingsController < ApplicationController
|
||||
@paused_mailings = @window_paused_mailings
|
||||
@completed_today = @mailings.count { |mailing| mailing.sent? && mailing.completed_at&.to_date == Time.zone.today }
|
||||
@failed_open = @mailings.sum(&:failed_count)
|
||||
@hourly_throughput = Mailings::HourlyThroughput.new(current_project)
|
||||
end
|
||||
|
||||
def new
|
||||
|
||||
@@ -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
|
||||
@@ -26,11 +26,21 @@
|
||||
</div>
|
||||
<% end %>
|
||||
|
||||
<div class="grid grid-cols-2 gap-3 xl:grid-cols-4">
|
||||
<div class="grid grid-cols-2 gap-3 md:grid-cols-3 xl:grid-cols-5">
|
||||
<div class="<%= card_class %> p-4">
|
||||
<div class="text-xs uppercase tracking-wide text-zinc-500">In corso</div>
|
||||
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= @active_mailings.size %></div>
|
||||
</div>
|
||||
<div class="<%= card_class %> p-4">
|
||||
<div class="text-xs uppercase tracking-wide text-zinc-500">Mail / ora</div>
|
||||
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= @hourly_throughput.sent %></div>
|
||||
<div class="mt-1 text-xs text-zinc-500">
|
||||
<%= @hourly_throughput.recent_sent %> ultimi 15 min
|
||||
<% if @hourly_throughput.failed.positive? %>
|
||||
· <%= @hourly_throughput.failed %> scodate in errore
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
<div class="<%= card_class %> p-4">
|
||||
<div class="text-xs uppercase tracking-wide text-zinc-500">In pausa (fascia)</div>
|
||||
<div class="mt-1 text-2xl font-semibold tabular-nums"><%= @paused_mailings.size %></div>
|
||||
|
||||
Reference in New Issue
Block a user