mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Fix overland batch payload processing
This commit is contained in:
parent
605144e55d
commit
50798b5bb1
4 changed files with 25 additions and 2 deletions
|
|
@ -15,6 +15,10 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
|||
|
||||
- `MAP_CENTER` env var from the `docker-compose.yml` file. This variable was used to set the default center of the map, but it is not needed anymore, as the map center is now hardcoded in the application. ⚠️ Feel free to remove this variable from your `docker-compose.yml` file. ⚠️
|
||||
|
||||
### Fixed
|
||||
|
||||
- Fixed a bug where Overland batch payload was not being processed due to missing coordinates in the payload. Now, if the coordinates are missing, the single point is skipped and the rest are being processed.
|
||||
|
||||
---
|
||||
|
||||
## [0.8.5] — 2024-07-08
|
||||
|
|
|
|||
|
|
@ -10,6 +10,8 @@ class Overland::Params
|
|||
|
||||
def call
|
||||
points.map do |point|
|
||||
next if point[:geometry].nil? || point.dig(:properties, :timestamp).nil?
|
||||
|
||||
{
|
||||
latitude: point[:geometry][:coordinates][1],
|
||||
longitude: point[:geometry][:coordinates][0],
|
||||
|
|
@ -24,7 +26,7 @@ class Overland::Params
|
|||
vertical_accuracy: point[:properties][:vertical_accuracy],
|
||||
raw_data: point
|
||||
}
|
||||
end
|
||||
end.compact
|
||||
end
|
||||
|
||||
private
|
||||
|
|
|
|||
11
spec/fixtures/files/overland/geodata.json
vendored
11
spec/fixtures/files/overland/geodata.json
vendored
|
|
@ -26,6 +26,17 @@
|
|||
"battery_state": "charging",
|
||||
"battery_level": 0.89
|
||||
}
|
||||
},
|
||||
{
|
||||
"type": "Feature",
|
||||
"properties": {
|
||||
"wifi": "",
|
||||
"timestamp": "2024-07-07T17:46:39Z",
|
||||
"device_id": "iphone",
|
||||
"battery_state": "unplugged",
|
||||
"battery_level": 0.55,
|
||||
"action": "will_terminate"
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'rails_helper'
|
||||
|
||||
RSpec.describe Overland::Params do
|
||||
describe '#call' do
|
||||
# This file contains one valid point and one invalid point w/out coordinates
|
||||
let(:file_path) { 'spec/fixtures/files/overland/geodata.json' }
|
||||
let(:file) { File.open(file_path) }
|
||||
let(:json) { JSON.parse(file.read) }
|
||||
|
|
@ -47,6 +50,9 @@ RSpec.describe Overland::Params do
|
|||
it 'returns a hash with the correct values' do
|
||||
expect(params[0]).to eq(expected_json)
|
||||
end
|
||||
|
||||
it 'returns the correct number of points' do
|
||||
expect(params.size).to eq(1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue