Skip to content

Commit

Permalink
use rails insert all
Browse files Browse the repository at this point in the history
  • Loading branch information
hooopo committed Mar 24, 2021
1 parent c7fb448 commit 49e5941
Showing 1 changed file with 1 addition and 6 deletions.
7 changes: 1 addition & 6 deletions app/jobs/event_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,7 @@ class EventJob
def perform(*args)
Thread.current[:bq] ||= BufferQueue.new(max_batch_size: (ENV["MAX_BATCH_SIZE"] || 100).to_i, execution_interval: (ENV["EXECUTION_INTERVAL"] || 1).to_i) do |batch|
puts "bulk insert #{batch.size} records"
Hyper::Event.import(
EventJob::COLUMN_NAMES,
batch.flatten.map { |attr| Hyper::Event.new(attr) },
validate: false,
timestamps: false
) unless batch.empty?
Hyper::Event.insert_all!(batch)
end
params, form, request = args

Expand Down

0 comments on commit 49e5941

Please sign in to comment.