corretti bug sull'invio email
CI / scan_ruby (push) Failing after 12m46s
CI / scan_js (push) Successful in 12m35s
CI / lint (push) Failing after 12m46s

This commit is contained in:
2026-09-10 17:08:50 +02:00
parent 36b3ffe507
commit 3f7794959e
8 changed files with 59 additions and 6 deletions
+2 -1
View File
@@ -306,6 +306,7 @@ class MailingsController < ApplicationController
def load_audience_options
orgs = Organization.for_project(current_project)
@sport_options = orgs.where.not(sport: [nil, ""]).distinct.order(:sport).pluck(:sport)
@country_options = orgs.where.not(country: [nil, ""]).distinct.order(:country).pluck(:country)
@region_options = orgs.where.not(region: [nil, ""]).distinct.order(:region).pluck(:region)
@province_options = orgs.where.not(province: [nil, ""]).distinct.order(:province).pluck(:province)
@history_mailings = Mailing.for_project(current_project).where.not(id: @mailing.id).recent
@@ -329,7 +330,7 @@ class MailingsController < ApplicationController
ActionController::Parameters.new(copied).permit(
:preset, :list_min, :list_max, :estimated_value, :history_kind, :history_days,
:history_mailing_id, :never_contacted, :exclude_customers, :exclude_mailed_within_days,
sports: [], team_genders: [], regions: [], provinces: [], streaming_statuses: [], statuses: [],
sports: [], countries: [], team_genders: [], regions: [], provinces: [], streaming_statuses: [], statuses: [],
send_statuses: [], ab_variants: [], pipeline_stages: [],
exclude_received_mailing_ids: [], exclude_opened_mailing_ids: []
)
+6 -1
View File
@@ -115,7 +115,12 @@ class MailingRecipient < ApplicationRecord
end
MAX_SMTP_DEFERS = 8
DEFER_PATTERN = /tentativo (\d+)\//
# Deve combaciare col testo generato sotto ("Da ritentare (N/8): ..."),
# altrimenti smtp_defer_count legge sempre 0 e il retry diventa infinito
# (bug osservato in produzione: un destinatario con SMTP EOF permanente
# veniva ritentato ogni 30s all'infinito, bloccando gli altri destinatari
# in errore della stessa mailing).
DEFER_PATTERN = /Da ritentare \((\d+)\//
def defer_or_fail!(error)
attempt = smtp_defer_count + 1
+2 -1
View File
@@ -5,7 +5,7 @@ module Mailings
VALUE_MODES = %w[any present blank].freeze
ARRAY_KEYS = %w[
sports team_genders regions provinces streaming_statuses statuses
sports countries team_genders regions provinces streaming_statuses statuses
send_statuses ab_variants pipeline_stages
exclude_received_mailing_ids exclude_opened_mailing_ids
].freeze
@@ -46,6 +46,7 @@ module Mailings
def summary_parts
parts = [Catalog.label_for(Catalog::MAILING_AUDIENCES, preset)]
parts << "sport: #{Array(@data["sports"]).join(", ")}" if @data["sports"].present?
parts << "nazione: #{Array(@data["countries"]).join(", ")}" if @data["countries"].present?
parts << "M/F: #{Array(@data["team_genders"]).map { |g| Catalog.label_for(Catalog::TEAM_GENDERS, g) }.join(", ")}" if @data["team_genders"].present?
parts << "regione: #{Array(@data["regions"]).join(", ")}" if @data["regions"].present?
parts << "provincia: #{Array(@data["provinces"]).join(", ")}" if @data["provinces"].present?
+1
View File
@@ -44,6 +44,7 @@ module Mailings
def apply_organization_filters(scope)
scope = scope.where(sport: @filters["sports"]) if @filters["sports"].present?
scope = scope.where(country: @filters["countries"]) if @filters["countries"].present?
scope = scope.where(team_gender: @filters["team_genders"]) if @filters["team_genders"].present?
scope = scope.where(region: @filters["regions"]) if @filters["regions"].present?
scope = scope.where(province: @filters["provinces"]) if @filters["provinces"].present?
+6 -1
View File
@@ -48,11 +48,16 @@ class Mailings::OutboundQueue
end
def next_queued
# Sceglie il destinatario piu vecchio (per priorita/updated_at) TRA le mailing
# la cui finestra di invio e attualmente aperta. Prima si sceglieva il piu vecchio
# in assoluto: se apparteneva a una mailing con finestra chiusa, drain_one!
# restituiva :closed e si fermava, bloccando l'intera coda condivisa anche per
# le mailing senza vincoli orari (bug: coda bloccata da mailing con orario chiuso).
queued_scope.order(
Arel.sql(
"CASE WHEN mailing_recipients.error_message IS NULL OR mailing_recipients.error_message = '' THEN 0 ELSE 1 END, mailing_recipients.updated_at ASC, mailing_recipients.id ASC"
)
).first
).includes(:mailing).find { |r| Mailings::SendClock.new(r.mailing).open? }
end
def queued_scope
+7 -2
View File
@@ -29,7 +29,7 @@
<section class="<%= card_class %> space-y-4 p-4 md:p-6">
<div>
<h2 class="text-base font-semibold">Chi deve ricevere questa email?</h2>
<p class="mt-1 text-sm text-zinc-500">Lista di partenza, sport, regione e chi non ha mai ricevuto una email. Il resto è opzionale.</p>
<p class="mt-1 text-sm text-zinc-500">Lista di partenza, sport, nazione, regione e chi non ha mai ricevuto una email. Il resto è opzionale.</p>
</div>
<div>
@@ -47,12 +47,17 @@
</span>
</label>
<div class="grid gap-4 md:grid-cols-2">
<div class="grid gap-4 md:grid-cols-3">
<div>
<label class="mb-1 block text-sm font-medium">Sport</label>
<%= render "mailings/audience_choices", name: "filters[sports]",
choices: @sport_options.map { |sport| [sport, sport] }, selected: @filters["sports"] %>
</div>
<div>
<label class="mb-1 block text-sm font-medium">Nazione</label>
<%= render "mailings/audience_choices", name: "filters[countries]",
choices: @country_options.map { |country| [country, country] }, selected: @filters["countries"] %>
</div>
<div>
<label class="mb-1 block text-sm font-medium">Regione</label>
<%= render "mailings/audience_choices", name: "filters[regions]",