diff --git a/app/jobs/import_job.rb b/app/jobs/import_job.rb
index a07cfa46..298c2770 100644
--- a/app/jobs/import_job.rb
+++ b/app/jobs/import_job.rb
@@ -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
diff --git a/app/services/google_maps/semantic_history_parser.rb b/app/services/google_maps/semantic_history_parser.rb
index 83d2486b..b7181eff 100644
--- a/app/services/google_maps/semantic_history_parser.rb
+++ b/app/services/google_maps/semantic_history_parser.rb
@@ -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
diff --git a/app/services/imports/watcher.rb b/app/services/imports/watcher.rb
index 98ef06da..b3922baa 100644
--- a/app/services/imports/watcher.rb
+++ b/app/services/imports/watcher.rb
@@ -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
\ No newline at end of file
diff --git a/spec/fixtures/files/watched/user@domain.com/2023_January.json b/spec/fixtures/files/watched/user@domain.com/2023_January.json
index 237a8e2e..1a25ab3c 100644
--- a/spec/fixtures/files/watched/user@domain.com/2023_January.json
+++ b/spec/fixtures/files/watched/user@domain.com/2023_January.json
@@ -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"
+ }
}
]
}
\ No newline at end of file
diff --git a/spec/fixtures/files/watched/user@domain.com/Records.json b/spec/fixtures/files/watched/user@domain.com/Records.json
index 67be4f16..930ca395 100644
--- a/spec/fixtures/files/watched/user@domain.com/Records.json
+++ b/spec/fixtures/files/watched/user@domain.com/Records.json
@@ -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"
}
]
}
\ No newline at end of file
diff --git a/spec/fixtures/files/watched/user@domain.com/export_same_points.json b/spec/fixtures/files/watched/user@domain.com/export_same_points.json
index 2ecfb883..7951ef5a 100644
--- a/spec/fixtures/files/watched/user@domain.com/export_same_points.json
+++ b/spec/fixtures/files/watched/user@domain.com/export_same_points.json
@@ -1 +1,175 @@
-{"type":"FeatureCollection","features":[{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}},{"type":"Feature","geometry":{"type":"Point","coordinates":["37.6173","55.755826"]},"properties":{"battery_status":"unplugged","ping":"MyString","battery":1,"tracker_id":"MyString","topic":"MyString","altitude":1,"longitude":"37.6173","velocity":"0","trigger":"background_event","bssid":"MyString","ssid":"MyString","connection":"wifi","vertical_accuracy":1,"accuracy":1,"timestamp":1609459200,"latitude":"55.755826","mode":1,"inrids":[],"in_regions":[],"city":null,"country":null,"geodata":{}}}]}
+{
+ "type": "FeatureCollection",
+ "features": [
+ {
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ "37.6173",
+ "55.755826"
+ ]
+ },
+ "properties": {
+ "battery_status": "unplugged",
+ "ping": "MyString",
+ "battery": 1,
+ "tracker_id": "MyString",
+ "topic": "MyString",
+ "altitude": 1,
+ "longitude": "37.6173",
+ "velocity": "0",
+ "trigger": "background_event",
+ "bssid": "MyString",
+ "ssid": "MyString",
+ "connection": "wifi",
+ "vertical_accuracy": 1,
+ "accuracy": 1,
+ "timestamp": 1609459200,
+ "latitude": "55.755826",
+ "mode": 1,
+ "inrids": [],
+ "in_regions": [],
+ "city": null,
+ "country": null,
+ "geodata": {}
+ }
+ },
+ {
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ "37.6173",
+ "55.755826"
+ ]
+ },
+ "properties": {
+ "battery_status": "unplugged",
+ "ping": "MyString",
+ "battery": 1,
+ "tracker_id": "MyString",
+ "topic": "MyString",
+ "altitude": 1,
+ "longitude": "37.6173",
+ "velocity": "0",
+ "trigger": "background_event",
+ "bssid": "MyString",
+ "ssid": "MyString",
+ "connection": "wifi",
+ "vertical_accuracy": 1,
+ "accuracy": 1,
+ "timestamp": 1609459200,
+ "latitude": "55.755826",
+ "mode": 1,
+ "inrids": [],
+ "in_regions": [],
+ "city": null,
+ "country": null,
+ "geodata": {}
+ }
+ },
+ {
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ "37.6173",
+ "55.755826"
+ ]
+ },
+ "properties": {
+ "battery_status": "unplugged",
+ "ping": "MyString",
+ "battery": 1,
+ "tracker_id": "MyString",
+ "topic": "MyString",
+ "altitude": 1,
+ "longitude": "37.6173",
+ "velocity": "0",
+ "trigger": "background_event",
+ "bssid": "MyString",
+ "ssid": "MyString",
+ "connection": "wifi",
+ "vertical_accuracy": 1,
+ "accuracy": 1,
+ "timestamp": 1609459200,
+ "latitude": "55.755826",
+ "mode": 1,
+ "inrids": [],
+ "in_regions": [],
+ "city": null,
+ "country": null,
+ "geodata": {}
+ }
+ },
+ {
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ "37.6173",
+ "55.755826"
+ ]
+ },
+ "properties": {
+ "battery_status": "unplugged",
+ "ping": "MyString",
+ "battery": 1,
+ "tracker_id": "MyString",
+ "topic": "MyString",
+ "altitude": 1,
+ "longitude": "37.6173",
+ "velocity": "0",
+ "trigger": "background_event",
+ "bssid": "MyString",
+ "ssid": "MyString",
+ "connection": "wifi",
+ "vertical_accuracy": 1,
+ "accuracy": 1,
+ "timestamp": 1609459200,
+ "latitude": "55.755826",
+ "mode": 1,
+ "inrids": [],
+ "in_regions": [],
+ "city": null,
+ "country": null,
+ "geodata": {}
+ }
+ },
+ {
+ "type": "Feature",
+ "geometry": {
+ "type": "Point",
+ "coordinates": [
+ "37.6173",
+ "55.755826"
+ ]
+ },
+ "properties": {
+ "battery_status": "unplugged",
+ "ping": "MyString",
+ "battery": 1,
+ "tracker_id": "MyString",
+ "topic": "MyString",
+ "altitude": 1,
+ "longitude": "37.6173",
+ "velocity": "0",
+ "trigger": "background_event",
+ "bssid": "MyString",
+ "ssid": "MyString",
+ "connection": "wifi",
+ "vertical_accuracy": 1,
+ "accuracy": 1,
+ "timestamp": 1609459200,
+ "latitude": "55.755826",
+ "mode": 1,
+ "inrids": [],
+ "in_regions": [],
+ "city": null,
+ "country": null,
+ "geodata": {}
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/spec/fixtures/files/watched/user@domain.com/gpx_track_single_segment.gpx b/spec/fixtures/files/watched/user@domain.com/gpx_track_single_segment.gpx
index 3176fb4f..7c73a8ac 100644
--- a/spec/fixtures/files/watched/user@domain.com/gpx_track_single_segment.gpx
+++ b/spec/fixtures/files/watched/user@domain.com/gpx_track_single_segment.gpx
@@ -34,1206 +34,6 @@
811.41
-
- 808.11
-
-
-
- 805.33
-
-
-
- 802.85
-
-
-
- 800.8
-
-
-
- 798.9
-
-
-
- 797.19
-
-
-
- 795.8
-
-
-
- 794.31
-
-
-
- 793.25
-
-
-
- 792.19
-
-
-
- 791.44
-
-
-
- 791.24
-
-
-
- 791.47
-
-
-
- 792.04
-
-
-
- 792.18
-
-
-
- 793.94
-
-
-
- 795.29
-
-
-
- 796.89
-
-
-
- 798.7
-
-
-
- 801.44
-
-
-
- 803.97
-
-
-
- 806.6
-
-
-
- 809.27
-
-
-
- 811.96
-
-
-
- 814.62
-
-
-
- 817.54
-
-
-
- 820.18
-
-
-
- 822.76
-
-
-
- 825.25
-
-
-
- 827.89
-
-
-
- 830.82
-
-
-
- 833.17
-
-
-
- 835.42
-
-
-
- 837.9
-
-
-
- 839.89
-
-
-
- 841.98
-
-
-
- 844.17
-
-
-
- 846.01
-
-
-
- 847.32
-
-
-
- 848.51
-
-
-
- 849.54
-
-
-
- 850.3
-
-
-
- 850.74
-
-
-
- 851.11
-
-
-
- 851.31
-
-
-
- 851.37
-
-
-
- 851.36
-
-
-
- 851.21
-
-
-
- 851.04
-
-
-
- 850.86
-
-
-
- 850.41
-
-
-
- 849.94
-
-
-
- 849.54
-
-
-
- 849.08
-
-
-
- 848.67
-
-
-
- 848.36
-
-
-
- 848.08
-
-
-
- 847.87
-
-
-
- 847.77
-
-
-
- 847.74
-
-
-
- 847.75
-
-
-
- 847.81
-
-
-
- 847.96
-
-
-
- 848.17
-
-
-
- 848.37
-
-
-
- 848.68
-
-
-
- 849.01
-
-
-
- 849.24
-
-
-
- 849.47
-
-
-
- 849.7
-
-
-
- 849.88
-
-
-
- 850.1
-
-
-
- 850.25
-
-
-
- 850.38
-
-
-
- 850.47
-
-
-
- 850.46
-
-
-
- 850.35
-
-
-
- 850.35
-
-
-
- 850.02
-
-
-
- 849.6
-
-
-
- 849.05
-
-
-
- 848.37
-
-
-
- 847.54
-
-
-
- 846.57
-
-
-
- 845.55
-
-
-
- 844.29
-
-
-
- 842.85
-
-
-
- 841.43
-
-
-
- 839.98
-
-
-
- 838.63
-
-
-
- 837.18
-
-
-
- 835.48
-
-
-
- 833.92
-
-
-
- 832.43
-
-
-
- 831.06
-
-
-
- 829.84
-
-
-
- 829.04
-
-
-
- 828.42
-
-
-
- 828.15
-
-
-
- 828.11
-
-
-
- 828.51
-
-
-
- 829.55
-
-
-
- 830.31
-
-
-
- 831.12
-
-
-
- 831.93
-
-
-
- 832.91
-
-
-
- 833.85
-
-
-
- 834.91
-
-
-
- 836.07
-
-
-
- 837.2
-
-
-
- 838.38
-
-
-
- 839.56
-
-
-
- 840.58
-
-
-
- 841.58
-
-
-
- 842.46
-
-
-
- 843.23
-
-
-
- 843.46
-
-
-
- 843.41
-
-
-
- 842.64
-
-
-
- 841.84
-
-
-
- 840.81
-
-
-
- 839.56
-
-
-
- 837.86
-
-
-
- 836.03
-
-
-
- 833.91
-
-
-
- 831.55
-
-
-
- 828.71
-
-
-
- 825.47
-
-
-
- 820.96
-
-
-
- 817.85
-
-
-
- 814.71
-
-
-
- 811.52
-
-
-
- 808.25
-
-
-
- 805.03
-
-
-
- 801.68
-
-
-
- 798.27
-
-
-
- 794.91
-
-
-
- 791.73
-
-
-
- 788.61
-
-
-
- 785.48
-
-
-
- 782.4
-
-
-
- 779.42
-
-
-
- 776.47
-
-
-
- 773.67
-
-
-
- 770.99
-
-
-
- 768.4
-
-
-
- 765.66
-
-
-
- 763.1
-
-
-
- 760.26
-
-
-
- 757.88
-
-
-
- 755.75
-
-
-
- 753.7
-
-
-
- 751.75
-
-
-
- 749.94
-
-
-
- 748.17
-
-
-
- 746.34
-
-
-
- 744.47
-
-
-
- 743.18
-
-
-
- 742.0
-
-
-
- 741.01
-
-
-
- 740.17
-
-
-
- 739.53
-
-
-
- 738.88
-
-
-
- 738.42
-
-
-
- 738.16
-
-
-
- 738.01
-
-
-
- 738.01
-
-
-
- 738.11
-
-
-
- 738.36
-
-
-
- 738.8
-
-
-
- 739.13
-
-
-
- 739.78
-
-
-
- 740.12
-
-
-
- 740.55
-
-
-
- 740.93
-
-
-
- 741.31
-
-
-
- 741.6
-
-
-
- 741.82
-
-
-
- 741.89
-
-
-
- 741.94
-
-
-
- 741.89
-
-
-
- 742.0
-
-
-
- 742.05
-
-
-
- 742.17
-
-
-
- 742.28
-
-
-
- 742.49
-
-
-
- 742.74
-
-
-
- 742.86
-
-
-
- 743.34
-
-
-
- 744.01
-
-
-
- 744.96
-
-
-
- 746.14
-
-
-
- 747.41
-
-
-
- 748.68
-
-
-
- 750.03
-
-
-
- 751.57
-
-
-
- 753.47
-
-
-
- 755.4
-
-
-
- 757.49
-
-
-
- 759.68
-
-
-
- 762.09
-
-
-
- 764.56
-
-
-
- 767.4
-
-
-
- 770.3
-
-
-
- 773.45
-
-
-
- 776.83
-
-
-
- 780.51
-
-
-
- 783.74
-
-
-
- 786.94
-
-
-
- 790.76
-
-
-
- 794.06
-
-
-
- 797.36
-
-
-
- 800.75
-
-
-
- 804.12
-
-
-
- 807.53
-
-
-
- 811.02
-
-
-
- 814.61
-
-
-
- 818.13
-
-
-
- 821.6
-
-
-
- 825.29
-
-
-
- 828.89
-
-
-
- 832.37
-
-
-
- 836.28
-
-
-
- 839.49
-
-
-
- 842.19
-
-
-
- 844.74
-
-
-
- 847.21
-
-
-
- 849.34
-
-
-
- 851.3
-
-
-
- 852.93
-
-
-
- 854.35
-
-
-
- 855.69
-
-
-
- 856.86
-
-
-
- 857.72
-
-
-
- 858.43
-
-
-
- 858.78
-
-
-
- 859.01
-
-
-
- 859.0
-
-
-
- 858.97
-
-
-
- 859.21
-
-
-
- 859.45
-
-
-
- 859.73
-
-
-
- 860.06
-
-
-
- 860.45
-
-
-
- 861.08
-
-
-
- 861.61
-
-
-
- 862.29
-
-
-
- 863.0
-
-
-
- 863.9
-
-
-
- 864.96
-
-
-
- 866.07
-
-
-
- 867.3
-
-
-
- 869.0
-
-
-
- 870.45
-
-
-
- 871.97
-
-
-
- 873.37
-
-
-
- 874.8
-
-
-
- 876.17
-
-
-
- 877.6
-
-
-
- 879.15
-
-
-
- 880.87
-
-
-
- 882.54
-
-
-
- 884.28
-
-
-
- 886.01
-
-
-
- 887.84
-
-
-
- 889.62
-
-
-
- 891.29
-
-
-
- 892.83
-
-
-
- 893.87
-
-
-
- 894.78
-
-
-
- 895.66
-
-
-
- 896.51
-
-
-
- 896.83
-
-
-
- 896.95
-
-
-
- 896.98
-
-
-
- 896.67
-
-
-
- 896.92
-
-
-
- 897.13
-
-
-
- 897.08
-
-
-
- 897.65
-
-
-
- 898.62
-
-
-
- 899.59
-
-
-
- 900.3
-
-
-
- 901.06
-
-
-
- 901.98
-
-
-
- 902.94
-
-
-
- 904.14
-
-
-
- 905.06
-
-
-
- 905.5
-
-
-
- 905.8
-
-
-
- 905.47
-
-
-
- 905.91
-
-
-
- 906.01
-
-
-
- 905.66
-
-
-
- 904.85
-
-
-
- 904.4
-
-
-
- 903.49
-
-
-
- 903.02
-
-
-
- 901.8
-
-
-
- 901.42
-
-
\ No newline at end of file
diff --git a/spec/services/imports/watcher_spec.rb b/spec/services/imports/watcher_spec.rb
index 05ed8759..65bcd19a 100644
--- a/spec/services/imports/watcher_spec.rb
+++ b/spec/services/imports/watcher_spec.rb
@@ -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