Files
baffle-hub/lib/tasks/events.rake
2025-11-13 08:35:00 +11:00

37 lines
1.1 KiB
Ruby

# frozen_string_literal: true
namespace :events do
desc "Backfill network intelligence data for events"
task backfill_network_intelligence: :environment do
batch_size = ENV['BATCH_SIZE']&.to_i || 10_000
Event.backfill_network_intelligence!(batch_size: batch_size)
end
desc "Show backfill progress"
task backfill_progress: :environment do
total = Event.count
with_country = Event.where.not(country: nil).count
without_country = Event.where(country: nil).count
percent = (with_country.to_f / total * 100).round(1)
puts "=" * 60
puts "Network Intelligence Backfill Progress"
puts "=" * 60
puts "Total events: #{total}"
puts "With network data: #{with_country} (#{percent}%)"
puts "Missing network data: #{without_country}"
puts "=" * 60
if without_country > 0
puts
puts "To continue backfill:"
puts " rails events:backfill_network_intelligence"
puts
puts "Or with custom batch size:"
puts " BATCH_SIZE=5000 rails events:backfill_network_intelligence"
else
puts "✓ Backfill complete!"
end
end
end