Rende usabili i filtri destinatari e permette di eliminare le bozze email.
Le listbox non applicavano sport e altri criteri; ora i filtri sono checkbox, c'è «mai contattati» e dal cruscotto si cancellano le bozze. La lista organizzazioni allinea le colonne al foglio campagna. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -91,7 +91,7 @@ module Mailings
|
||||
end
|
||||
|
||||
def history_active?
|
||||
history_kind.present?
|
||||
history_kind.present? && history_kind != "never"
|
||||
end
|
||||
|
||||
def organization_extra_active?
|
||||
@@ -115,7 +115,7 @@ module Mailings
|
||||
|
||||
def history_summary
|
||||
case history_kind
|
||||
when "never" then "mai ricevuta una campagna"
|
||||
when "never" then "mai contattati via email"
|
||||
when "received" then "già ricevuta campagna ##{history_mailing_id}"
|
||||
when "not_received" then "non ricevuta campagna ##{history_mailing_id}"
|
||||
when "opened" then "aperta campagna ##{history_mailing_id}"
|
||||
@@ -137,6 +137,7 @@ module Mailings
|
||||
data["list_max"] = integer_or_nil(source["list_max"])
|
||||
data["estimated_value"] = source["estimated_value"].presence_in(VALUE_MODES) || "any"
|
||||
data["history_kind"] = source["history_kind"].presence_in(HISTORY_KINDS)
|
||||
data["history_kind"] = "never" if ActiveModel::Type::Boolean.new.cast(source["never_contacted"])
|
||||
data["history_mailing_id"] = integer_or_nil(source["history_mailing_id"])
|
||||
data["history_days"] = integer_or_nil(source["history_days"])
|
||||
data["exclude_customers"] = ActiveModel::Type::Boolean.new.cast(source["exclude_customers"]) || false
|
||||
|
||||
@@ -84,7 +84,7 @@ module Mailings
|
||||
def apply_history_filters(scope)
|
||||
case @filters.history_kind
|
||||
when "never"
|
||||
scope.where.not(id: sent_org_ids)
|
||||
scope.where.not(id: sent_org_ids).where.not(id: emailed_activity_org_ids)
|
||||
when "received"
|
||||
scope.where(id: sent_org_ids(mailing_id: @filters.history_mailing_id))
|
||||
when "not_received"
|
||||
@@ -127,6 +127,10 @@ module Mailings
|
||||
Opportunity.where(project_id: @project.id)
|
||||
end
|
||||
|
||||
def emailed_activity_org_ids
|
||||
Activity.where(activity_type: "email_sent", organization_id: Organization.for_project(@project).select(:id)).select(:organization_id)
|
||||
end
|
||||
|
||||
def sent_org_ids(mailing_id: nil, since: nil)
|
||||
recips = history_recipients.where(status: "sent")
|
||||
recips = recips.where(mailing_id: mailing_id) if mailing_id.present?
|
||||
|
||||
Reference in New Issue
Block a user