Fix Owntracks .rec file import

This commit is contained in:
Eugene Burmakin 2024-10-19 19:29:43 +02:00
parent 0f3d6237c7
commit 50b77cc493
6 changed files with 32 additions and 34 deletions

View file

@ -1 +1 @@
0.15.5
0.15.6

View file

@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/).
# 0.15.6 - 2024-10-19
### Fixed
- Import of Owntracks' .rec files now correctly imports points. Previously, the import was failing due to incorrect parsing of the file.
# 0.15.5 - 2024-10-16
### Fixed

File diff suppressed because one or more lines are too long

View file

@ -10,7 +10,7 @@ class OwnTracks::ExportParser
end
def call
points_data = parse_data
points_data = data.map { |point| OwnTracks::Params.new(point).call }
points_data.each do |point_data|
next if Point.exists?(
@ -28,12 +28,4 @@ class OwnTracks::ExportParser
point.save
end
end
private
def parse_data
json = OwnTracks::RecParser.new(data).call
json.map { |point| OwnTracks::Params.new(point).call }
end
end

View file

@ -5,6 +5,6 @@ FactoryBot.define do
user
name { 'APRIL_2013.json' }
source { Import.sources[:owntracks] }
raw_data { File.read('spec/fixtures/files/owntracks/2024-03.rec') }
raw_data { OwnTracks::RecParser.new(File.read('spec/fixtures/files/owntracks/2024-03.rec')).call }
end
end

View file

@ -32,7 +32,7 @@ RSpec.describe OwnTracks::ExportParser do
'bssid' => 'b0:f2:8:45:94:33',
'trigger' => 'background_event',
'tracker_id' => 'RO',
'timestamp' => 1709283789,
'timestamp' => 1_709_283_789,
'inrids' => ['5f1d1b'],
'in_regions' => ['home'],
'topic' => 'owntracks/test/iPhone 12 Pro',
@ -49,7 +49,7 @@ RSpec.describe OwnTracks::ExportParser do
'lat' => 52.225,
'lon' => 13.332,
'tid' => 'RO',
'tst'=>1709283789,
'tst' => 1_709_283_789,
'vac' => 4,
'vel' => 0,
'SSID' => 'Home Wifi',