mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
27 lines
561 B
Ruby
27 lines
561 B
Ruby
# frozen_string_literal: true
|
|
|
|
class Points::CreateJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(params, user_id)
|
|
data = Points::Params.new(params, user_id).call
|
|
|
|
data.each_slice(1000) do |location_batch|
|
|
Point.upsert_all(
|
|
location_batch,
|
|
unique_by: %i[latitude longitude timestamp user_id]
|
|
)
|
|
end
|
|
end
|
|
|
|
private
|
|
|
|
def point_exists?(params, user_id)
|
|
Point.exists?(
|
|
latitude: params[:latitude],
|
|
longitude: params[:longitude],
|
|
timestamp: params[:timestamp],
|
|
user_id:
|
|
)
|
|
end
|
|
end
|