Merge pull request #173 from Freika/photon_reverse_geocoding

Implement support for custom Photon API host
This commit is contained in:
Evgenii Burmakin 2024-08-14 18:24:39 +02:00 committed by GitHub
commit 4439e06f2d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 29 additions and 18 deletions

View file

@ -1 +1 @@
0.9.8
0.9.10

View file

@ -4,3 +4,4 @@ DATABASE_PASSWORD=password
DATABASE_NAME=dawarich_development
DATABASE_PORT=5432
REDIS_URL=redis://localhost:6379/1
PHOTON_API_HOST='photon.komoot.io'

View file

@ -5,6 +5,11 @@ 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.9.10] — 2024-08-14
### Added
- PHOTON_API_HOST env variable to set the host of the Photon API. It will allow you to use your own Photon API instance instead of the default one.
## [0.9.9] — 2024-07-30

View file

@ -11,22 +11,22 @@ class OwnTracks::Params
{
latitude: params[:lat],
longitude: params[:lon],
battery_status: battery_status,
battery: params[:batt],
ping: params[:p],
altitude: params[:alt],
accuracy: params[:acc],
vertical_accuracy: params[:vac],
velocity: params[:vel],
connection: connection,
ssid: params[:SSID],
bssid: params[:BSSID],
trigger: trigger,
tracker_id: params[:tid],
timestamp: params[:tst].to_i,
inrids: params[:inrids],
in_regions: params[:inregions],
topic: params[:topic],
battery_status:,
connection:,
trigger:,
raw_data: params.deep_stringify_keys
}
end

View file

@ -2,3 +2,4 @@
MIN_MINUTES_SPENT_IN_CITY = ENV.fetch('MIN_MINUTES_SPENT_IN_CITY', 60).to_i
REVERSE_GEOCODING_ENABLED = ENV.fetch('REVERSE_GEOCODING_ENABLED', 'true') == 'true'
PHOTON_API_HOST = ENV.fetch('PHOTON_API_HOST', nil)

View file

@ -1,16 +1,18 @@
# frozen_string_literal: true
Geocoder.configure(
# geocoding service request timeout, in seconds (default 3):
# timeout: 5,
# set default units to kilometers:
settings = {
timeout: 5,
units: :km,
# caching (see Caching section below for details):
cache: Redis.new,
always_raise: :all,
cache_options: {
expiration: 1.day # Defaults to `nil`
# prefix: "another_key:" # Defaults to `geocoder:`
expiration: 1.day
}
)
}
if defined?(PHOTON_API_HOST)
settings[:lookup] = :photon
settings[:photon] = { host: PHOTON_API_HOST }
end
Geocoder.configure(settings)

View file

@ -8,9 +8,11 @@ RSpec.describe AreaVisitsCalculationSchedulingJob, type: :job do
let(:user) { create(:user) }
it 'calls the AreaVisitsCalculationService' do
expect(AreaVisitsCalculatingJob).to receive(:perform_later).with(user.id).and_call_original
Sidekiq::Testing.inline! do
expect(AreaVisitsCalculatingJob).to receive(:perform_later).with(user.id).and_call_original
described_class.new.perform
described_class.new.perform
end
end
end
end

View file

@ -27,9 +27,9 @@ RSpec.describe '/settings/users', type: :request do
context 'when user is an admin' do
let!(:admin) { create(:user, :admin) }
before { sign_in admin }
describe 'POST /create' do
before { sign_in admin }
context 'with valid parameters' do
it 'creates a new User' do
expect do