From ce7b391316ee5f8dfa448517be9cfd5ad0395953 Mon Sep 17 00:00:00 2001 From: Eugene Burmakin Date: Sun, 5 May 2024 12:03:25 +0200 Subject: [PATCH] Add a new release to the CHANGELOG.md file and rename env var --- CHANGELOG.md | 10 ++++++++++ README.md | 2 +- app/services/countries_and_cities.rb | 2 +- config/application.rb | 8 +++++--- config/initializers/00_constants.rb | 2 +- docker-compose.yml | 2 +- spec/models/stat_spec.rb | 2 +- spec/services/countries_and_cities_spec.rb | 4 ++-- 8 files changed, 22 insertions(+), 10 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index ba747858..755f9885 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,6 +5,16 @@ 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.2.0] — 2024-05-05 + +*Breaking changes:* + +This release changes how Dawarich handles a city visit threshold. Previously, the `MINIMUM_POINTS_IN_CITY` environment variable was used to determine the minimum *number of points* in a city to consider it as visited. Now, the `MIN_MINUTES_SPENT_IN_CITY` environment variable is used to determine the minimum *minutes* between two points to consider them as visited the same city. + +The logic behind this is the following: if you have a lot of points in a city, it doesn't mean you've spent a lot of time there, especially if your OwnTracks app was in "Move" mode. So, it's better to consider the time spent in a city rather than the number of points. + +In your docker-compose.yml file, you need to replace the `MINIMUM_POINTS_IN_CITY` environment variable with `MIN_MINUTES_SPENT_IN_CITY`. The default value is `60`, in minutes. + ## [0.1.9] — 2024-04-25 ### Added diff --git a/README.md b/README.md index 4086314d..f55fe385 100644 --- a/README.md +++ b/README.md @@ -41,7 +41,7 @@ Copy the contents of the `docker-compose.yml` file to your server and run `docke ## Environment variables ``` -CITY_VISIT_THRESHOLD — minimum minutes between two points to consider them as visited the same city, e.g. `60` +MIN_MINUTES_SPENT_IN_CITY — minimum minutes between two points to consider them as visited the same city, e.g. `60` MAP_CENTER — default map center, e.g. `55.7558,37.6176` TIME_ZONE — time zone, e.g. `Europe/Berlin` APPLICATION_HOST — host of the application, e.g. `localhost` or `dawarich.example.com` diff --git a/app/services/countries_and_cities.rb b/app/services/countries_and_cities.rb index 21324483..7ba4fb02 100644 --- a/app/services/countries_and_cities.rb +++ b/app/services/countries_and_cities.rb @@ -41,7 +41,7 @@ class CountriesAndCities def filter_cities(mapped_with_cities) # Remove cities where user stayed for less than 1 hour mapped_with_cities.transform_values do |cities| - cities.reject { |_, data| data[:stayed_for] < CITY_VISIT_THRESHOLD } + cities.reject { |_, data| data[:stayed_for] < MIN_MINUTES_SPENT_IN_CITY } end end diff --git a/config/application.rb b/config/application.rb index c79d1428..9320f3ce 100644 --- a/config/application.rb +++ b/config/application.rb @@ -1,6 +1,8 @@ -require_relative "boot" +# frozen_string_literal: true -require "rails/all" +require_relative 'boot' + +require 'rails/all' # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. @@ -14,7 +16,7 @@ module Dawarich # Please, add to the `ignore` list any other `lib` subdirectories that do # not contain `.rb` files, or that should not be reloaded or eager loaded. # Common ones are `templates`, `generators`, or `middleware`, for example. - config.autoload_lib(ignore: %w(assets tasks)) + config.autoload_lib(ignore: %w[assets tasks]) # Configuration for the application, engines, and railties goes here. # diff --git a/config/initializers/00_constants.rb b/config/initializers/00_constants.rb index 1192365d..52eae22b 100644 --- a/config/initializers/00_constants.rb +++ b/config/initializers/00_constants.rb @@ -1,5 +1,5 @@ # frozen_string_literal: true -CITY_VISIT_THRESHOLD = ENV.fetch('MINIMUM_POINTS_IN_CITY', 60).to_i +MIN_MINUTES_SPENT_IN_CITY = ENV.fetch('MIN_MINUTES_SPENT_IN_CITY', 60).to_i MAP_CENTER = ENV.fetch('MAP_CENTER', '[55.7522, 37.6156]') REVERSE_GEOCODING_ENABLED = ENV.fetch('REVERSE_GEOCODING_ENABLED', 'true') == 'true' diff --git a/docker-compose.yml b/docker-compose.yml index 67832bf1..64418e3a 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -40,7 +40,7 @@ services: DATABASE_USERNAME: postgres DATABASE_PASSWORD: password DATABASE_NAME: dawarich_development - CITY_VISIT_THRESHOLD: 60 + MIN_MINUTES_SPENT_IN_CITY: 60 APPLICATION_HOST: localhost depends_on: - dawarich_db diff --git a/spec/models/stat_spec.rb b/spec/models/stat_spec.rb index bc6a493c..535d64cc 100644 --- a/spec/models/stat_spec.rb +++ b/spec/models/stat_spec.rb @@ -18,7 +18,7 @@ RSpec.describe Stat, type: :model do let(:timestamp) { DateTime.new(year, 1, 1, 0, 0, 0) } before do - stub_const('CITY_VISIT_THRESHOLD', 60) + stub_const('MIN_MINUTES_SPENT_IN_CITY', 60) end context 'when there are points' do diff --git a/spec/services/countries_and_cities_spec.rb b/spec/services/countries_and_cities_spec.rb index 8489fade..99e7664f 100644 --- a/spec/services/countries_and_cities_spec.rb +++ b/spec/services/countries_and_cities_spec.rb @@ -27,9 +27,9 @@ RSpec.describe CountriesAndCities do ] end - context 'when CITY_VISIT_THRESHOLD is 60 (in minutes)' do + context 'when MIN_MINUTES_SPENT_IN_CITY is 60 (in minutes)' do before do - stub_const('CITY_VISIT_THRESHOLD', 60) + stub_const('MIN_MINUTES_SPENT_IN_CITY', 60) end context 'when user stayed in the city for more than 1 hour' do