2025-01-20 10:37:15 -05:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
|
|
|
|
|
class Points::CreateJob < ApplicationJob
|
2025-05-21 12:57:29 -04:00
|
|
|
queue_as :points
|
2025-01-20 10:37:15 -05:00
|
|
|
|
|
|
|
|
def perform(params, user_id)
|
2025-01-20 11:59:13 -05:00
|
|
|
data = Points::Params.new(params, user_id).call
|
2025-01-20 10:37:15 -05:00
|
|
|
|
2025-01-20 11:59:13 -05:00
|
|
|
data.each_slice(1000) do |location_batch|
|
|
|
|
|
Point.upsert_all(
|
|
|
|
|
location_batch,
|
2025-02-22 16:37:21 -05:00
|
|
|
unique_by: %i[lonlat timestamp user_id],
|
2025-01-20 14:41:26 -05:00
|
|
|
returning: false
|
2025-01-20 11:59:13 -05:00
|
|
|
)
|
2025-01-20 10:37:15 -05:00
|
|
|
end
|
|
|
|
|
end
|
|
|
|
|
end
|