Fix some blocked/allow laggards after migrating. Add DuckDB for outstanding analyitcs performance. Start adding an import for all bot networks
This commit is contained in:
47
app/jobs/import_bot_network_ranges_job.rb
Normal file
47
app/jobs/import_bot_network_ranges_job.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
# ImportBotNetworkRangesJob - Background job for importing bot network ranges
|
||||
#
|
||||
# Imports network ranges from official bot provider sources.
|
||||
# Runs asynchronously to avoid blocking the web interface.
|
||||
class ImportBotNetworkRangesJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(source_key, options = {})
|
||||
Rails.logger.info "Starting bot network range import for source: #{source_key}"
|
||||
|
||||
begin
|
||||
result = BotNetworkRangeImporter.import_from_source(source_key, options)
|
||||
|
||||
# Send notification or log completion
|
||||
Rails.logger.info "Successfully imported #{result[:imported]} ranges from #{result[:source]}"
|
||||
|
||||
# Optionally broadcast via Turbo Streams for real-time updates
|
||||
ActionCable.server.broadcast(
|
||||
"bot_imports",
|
||||
{
|
||||
source: source_key,
|
||||
status: 'completed',
|
||||
imported: result[:imported],
|
||||
message: "Successfully imported #{result[:imported]} ranges from #{result[:source]}"
|
||||
}
|
||||
)
|
||||
|
||||
rescue => e
|
||||
Rails.logger.error "Bot network range import failed for #{source_key}: #{e.message}"
|
||||
|
||||
# Broadcast error notification
|
||||
ActionCable.server.broadcast(
|
||||
"bot_imports",
|
||||
{
|
||||
source: source_key,
|
||||
status: 'error',
|
||||
error: e.message,
|
||||
message: "Failed to import from #{source_key}: #{e.message}"
|
||||
}
|
||||
)
|
||||
|
||||
raise e
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user