Add DeviceDetector and postres_cursor
This commit is contained in:
36
lib/tasks/events.rake
Normal file
36
lib/tasks/events.rake
Normal file
@@ -0,0 +1,36 @@
|
||||
# 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
|
||||
Reference in New Issue
Block a user