Importa i prospect Calcio a 5 senza toccare la Pallavolo e filtra le organizzazioni per sport.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -16,4 +16,32 @@ namespace :matchlivetv do
|
||||
abort "Import incompleto"
|
||||
end
|
||||
end
|
||||
|
||||
desc "Importa un foglio campagna senza cancellare le società già in CRM"
|
||||
task import_campaign: :environment do
|
||||
path = ENV["CAMPAIGN_CSV"].presence or abort "Imposta CAMPAIGN_CSV"
|
||||
sport = ENV["SPORT"].presence or abort "Imposta SPORT (es. Calcio a 5)"
|
||||
campaign = ENV["CAMPAIGN_NAME"].presence || "Campagna #{sport}"
|
||||
user = User.find_by(email: "admin@simplecrm.local") || User.find_by!(role: "admin")
|
||||
project = Project.find_by!(code: "matchlivetv")
|
||||
|
||||
puts "File: #{path}"
|
||||
puts "Sport: #{sport}"
|
||||
puts "Campagna: #{campaign}"
|
||||
result = CampaignImport::MatchlivetvLaunch.new(
|
||||
path: path,
|
||||
user: user,
|
||||
project: project,
|
||||
wipe: false,
|
||||
sport: sport,
|
||||
campaign_name: campaign
|
||||
).call
|
||||
puts "Società importate: #{result.imported}"
|
||||
puts "Duplicati saltati: #{result.skipped}"
|
||||
if result.errors.any?
|
||||
puts "Errori: #{result.errors.size}"
|
||||
result.errors.first(10).each { |err| puts " riga #{err[:line]} #{err[:name]}: #{err[:message]}" }
|
||||
abort "Import incompleto"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user