Aggiunge il rilevamento di invio e apertura delle email di campagna.
Ogni destinatario mostra se la mail è partita e se è stata aperta, con conteggi in dashboard. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -0,0 +1,24 @@
|
||||
class AddOpenTrackingToMailingRecipients < ActiveRecord::Migration[8.1]
|
||||
def change
|
||||
change_table :mailing_recipients do |t|
|
||||
t.string :tracking_token
|
||||
t.datetime :opened_at
|
||||
t.datetime :last_opened_at
|
||||
t.integer :open_count, null: false, default: 0
|
||||
end
|
||||
|
||||
reversible do |dir|
|
||||
dir.up do
|
||||
execute <<~SQL.squish
|
||||
UPDATE mailing_recipients
|
||||
SET tracking_token = replace(gen_random_uuid()::text, '-', '')
|
||||
WHERE tracking_token IS NULL
|
||||
SQL
|
||||
change_column_null :mailing_recipients, :tracking_token, false
|
||||
end
|
||||
end
|
||||
|
||||
add_index :mailing_recipients, :tracking_token, unique: true
|
||||
add_index :mailing_recipients, :opened_at
|
||||
end
|
||||
end
|
||||
Generated
+7
-1
@@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_08_17_234500) do
|
||||
ActiveRecord::Schema[8.1].define(version: 2026_08_20_110000) do
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "pg_catalog.plpgsql"
|
||||
|
||||
@@ -126,17 +126,23 @@ ActiveRecord::Schema[8.1].define(version: 2026_08_17_234500) do
|
||||
t.datetime "created_at", null: false
|
||||
t.string "email"
|
||||
t.text "error_message"
|
||||
t.datetime "last_opened_at"
|
||||
t.bigint "mailing_id", null: false
|
||||
t.integer "open_count", default: 0, null: false
|
||||
t.datetime "opened_at"
|
||||
t.bigint "organization_id", null: false
|
||||
t.string "rendered_subject"
|
||||
t.datetime "sent_at"
|
||||
t.string "skip_reason"
|
||||
t.string "status", default: "pending", null: false
|
||||
t.string "tracking_token", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.index ["ab_variant"], name: "index_mailing_recipients_on_ab_variant"
|
||||
t.index ["email"], name: "index_mailing_recipients_on_email"
|
||||
t.index ["mailing_id", "organization_id"], name: "idx_mailing_recipients_unique", unique: true
|
||||
t.index ["opened_at"], name: "index_mailing_recipients_on_opened_at"
|
||||
t.index ["status"], name: "index_mailing_recipients_on_status"
|
||||
t.index ["tracking_token"], name: "index_mailing_recipients_on_tracking_token", unique: true
|
||||
end
|
||||
|
||||
create_table "mailings", force: :cascade do |t|
|
||||
|
||||
Reference in New Issue
Block a user