mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
error: watcher does not create points
This commit is contained in:
parent
49be1fe5a1
commit
1f223142f3
8 changed files with 220 additions and 1202 deletions
|
|
@ -4,9 +4,13 @@ class ImportJob < ApplicationJob
|
|||
queue_as :imports
|
||||
|
||||
def perform(user_id, import_id)
|
||||
puts "ImportJob started for user_id: #{user_id}, import_id: #{import_id}"
|
||||
|
||||
user = User.find(user_id)
|
||||
import = user.imports.find(import_id)
|
||||
|
||||
import.process!
|
||||
puts "ImportJob finished for user_id: #{user_id}, import_id: #{import_id}"
|
||||
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -33,6 +33,8 @@ class GoogleMaps::SemanticHistoryParser
|
|||
)
|
||||
|
||||
broadcast_import_progress(import, index)
|
||||
puts "Created point: #{location['latitudeE7'] / 1e7}, #{location['longitudeE7'] / 1e7} at #{location['timestamp']}"
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -10,11 +10,13 @@ class Imports::Watcher
|
|||
user_directories.each do |user_email|
|
||||
user = User.find_by(email: user_email)
|
||||
next unless user
|
||||
puts "Processing directory for user: #{user.email}"
|
||||
|
||||
user_directory_path = File.join(WATCHED_DIR_PATH, user_email)
|
||||
file_names = file_names(user_directory_path)
|
||||
|
||||
file_names.each do |file_name|
|
||||
puts "Processing file: #{file_name}"
|
||||
process_file(user, user_directory_path, file_name)
|
||||
end
|
||||
end
|
||||
|
|
@ -51,8 +53,11 @@ class Imports::Watcher
|
|||
import.raw_data = raw_data(file_path, import.source)
|
||||
|
||||
import.save!
|
||||
puts "Import saved for file: #{file_name}"
|
||||
|
||||
|
||||
ImportJob.perform_later(user.id, import.id)
|
||||
puts "ImportJob enqueued for user_id: #{user.id}, import_id: #{import.id}"
|
||||
end
|
||||
|
||||
def find_or_initialize_import(user, file_name)
|
||||
|
|
@ -104,4 +109,4 @@ class Imports::Watcher
|
|||
raise UnsupportedSourceError, "Unsupported source: #{source}"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -52,6 +52,19 @@
|
|||
"properties": {
|
||||
"timestamp": "2023-01-02T14:00:00Z"
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"geometry": {
|
||||
"type": "Point",
|
||||
"coordinates": [
|
||||
14.42076,
|
||||
50.08804
|
||||
]
|
||||
},
|
||||
"properties": {
|
||||
"timestamp": "2023-01-02T16:00:00Z"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
@ -21,6 +21,20 @@
|
|||
"source": "WIFI",
|
||||
"deviceTag": 1184882232,
|
||||
"timestamp": "2013-03-01T05:17:39.849Z"
|
||||
},
|
||||
{
|
||||
"latitudeE7": 533700000,
|
||||
"longitudeE7": 836960000,
|
||||
"accuracy": 50,
|
||||
"source": "GPS",
|
||||
"timestamp": "2013-04-01T12:00:00.000Z"
|
||||
},
|
||||
{
|
||||
"latitudeE7": 533710000,
|
||||
"longitudeE7": 836970000,
|
||||
"accuracy": 30,
|
||||
"source": "GPS",
|
||||
"timestamp": "2013-05-01T08:30:00.000Z"
|
||||
}
|
||||
]
|
||||
}
|
||||
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large
Load diff
|
|
@ -29,6 +29,12 @@ RSpec.describe Imports::Watcher do
|
|||
it 'creates an import for the user' do
|
||||
expect { service }.to change(user.imports, :count).by(6)
|
||||
end
|
||||
|
||||
it 'creates points for the user' do
|
||||
initial_point_count = Point.count
|
||||
service
|
||||
expect(Point.count).to be > initial_point_count
|
||||
end
|
||||
end
|
||||
|
||||
context 'when the file has an invalid user email' do
|
||||
|
|
|
|||
Loading…
Reference in a new issue