mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
27 lines
583 B
Ruby
27 lines
583 B
Ruby
# frozen_string_literal: true
|
|
|
|
class ImportJob < ApplicationJob
|
|
queue_as :default
|
|
|
|
def perform(user_id, import_id)
|
|
user = User.find(user_id)
|
|
import = user.imports.find(import_id)
|
|
|
|
result = parser(import.source).new(import).call
|
|
|
|
import.update(
|
|
raw_points: result[:raw_points], doubles: result[:doubles], processed: result[:processed]
|
|
)
|
|
|
|
StatCreatingJob.perform_later(user_id)
|
|
end
|
|
|
|
private
|
|
|
|
def parser(source)
|
|
case source
|
|
when 'google' then GoogleMaps::TimelineParser
|
|
when 'owntracks' then OwnTracks::ExportParser
|
|
end
|
|
end
|
|
end
|