Add a new release to the CHANGELOG.md file and rename env var

This commit is contained in:
Eugene Burmakin 2024-05-05 12:03:25 +02:00
parent a333458756
commit ce7b391316
8 changed files with 22 additions and 10 deletions

View file

@ -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

View file

@ -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`

View file

@ -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

View file

@ -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.
#

View file

@ -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'

View file

@ -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

View file

@ -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

View file

@ -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