Permette di scegliere 12 ore, 24 ore o la settimana nello storico invii.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -55,7 +55,7 @@ class Mailings::HourlyThroughputTest < ActiveSupport::TestCase
|
||||
add_recipient status: "sent", sent_at: now - 13.hours, mailing: extra_mailing("Fuori finestra")
|
||||
|
||||
stats = Mailings::HourlyThroughput.new(@project, now: now)
|
||||
history = stats.hourly_history
|
||||
history = stats.history
|
||||
|
||||
assert_equal 12, history.size
|
||||
assert_equal now.beginning_of_hour, history.last[:at]
|
||||
@@ -66,6 +66,45 @@ class Mailings::HourlyThroughputTest < ActiveSupport::TestCase
|
||||
end
|
||||
end
|
||||
|
||||
test "includes the previous day when the range is 24 hours" do
|
||||
now = Time.zone.parse("2026-09-07 12:40")
|
||||
travel_to now do
|
||||
add_recipient status: "sent", sent_at: now - 20.hours
|
||||
|
||||
twelve = Mailings::HourlyThroughput.new(@project, now: now, range: "12h")
|
||||
day = Mailings::HourlyThroughput.new(@project, now: now, range: "24h")
|
||||
|
||||
assert_equal 0, twelve.history_total
|
||||
assert_equal 24, day.history.size
|
||||
assert_equal 1, day.history_total
|
||||
end
|
||||
end
|
||||
|
||||
test "groups the last week by day" do
|
||||
now = Time.zone.parse("2026-09-07 12:40")
|
||||
travel_to now do
|
||||
add_recipient status: "sent", sent_at: now - 3.days
|
||||
add_recipient status: "sent", sent_at: now - 8.days, mailing: extra_mailing("Vecchia")
|
||||
|
||||
stats = Mailings::HourlyThroughput.new(@project, now: now, range: "7d")
|
||||
history = stats.history
|
||||
|
||||
assert_equal 7, history.size
|
||||
assert_equal now.beginning_of_day, history.last[:at]
|
||||
assert_equal 1, history[-4][:count]
|
||||
assert_equal 0, history.last[:count]
|
||||
assert_equal 1, stats.history_total
|
||||
assert_equal "7d", stats.range_key
|
||||
end
|
||||
end
|
||||
|
||||
test "falls back to 12 hours for an unknown range" do
|
||||
stats = Mailings::HourlyThroughput.new(@project, range: "nope")
|
||||
|
||||
assert_equal "12h", stats.range_key
|
||||
assert_equal 12, stats.history.size
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def extra_mailing(name = "Altra campagna")
|
||||
|
||||
Reference in New Issue
Block a user