diff --git a/.app_version b/.app_version index bc859cbd..ac454c6a 100644 --- a/.app_version +++ b/.app_version @@ -1 +1 @@ -0.11.2 +0.12.0 diff --git a/CHANGELOG.md b/CHANGELOG.md index 28050078..5315fb1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -5,7 +5,7 @@ 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/). -## [Unreleased] +## [0.12.0] — 2024-08-25 The visit suggestion release. @@ -14,23 +14,15 @@ The visit suggestion release. 3. If you have enabled reverse geocoding and (optionally) provided Photon Api Host, Dawarich will try to reverse geocode your visit and suggest specific places you might have visited, such as cafes, restaurants, parks, etc. If reverse geocoding is not enabled, or Photon Api Host is not provided, Dawarich will not try to suggest places but you'll be able to rename the visit yourself. 4. You can confirm or decline the visit suggestion. If you confirm the visit, it will be added to your timeline. If you decline the visit, it will be removed from your timeline. You'll be able to see all your confirmed, declined and suggested visits on the Visits page. -- [x] Get places from Google Places API based on visit coordinates -- [x] Implement starting visit suggestion process after import of new points -- [x] Detect if the visit is an area visit and attach it to the area -- [x] Draw visit radius based on radius of points in the visit -- [x] Add a possibility to rename the visit - - [x] Make it look acceptable -- [ ] Make visits suggestion an idempotent process -- [ ] Places management: if visit is detected at a place with a name, suggest this name as a visit name - - [x] Separate page for places management - ### Added -- `PHOTON_API_HOST` environment variable to the `docker-compose.yml` file to allow user to set the Photon API hpst for reverse geocoding - A "Map" button to each visit on the Visits page to allow user to see the visit on the map - Visits suggestion functionality. Read more on that in the release description +- Click on the visit name allows user to rename the visit - Tabs to the Visits page to allow user to switch between confirmed, declined and suggested visits +- Places page to see and delete places suggested by Dawarich's visit suggestion process +- Importing a file will now trigger the visit suggestion process for the user ## [0.11.2] — 2024-08-22 diff --git a/README.md b/README.md index 8a30111d..ec04b13d 100644 --- a/README.md +++ b/README.md @@ -117,6 +117,7 @@ Feel free to change them both in the Account section. | APPLICATION_HOSTS | list of host of the application, e.g. `localhost,dawarich.example.com` | | BACKGROUND_PROCESSING_CONCURRENCY (only for dawarich_sidekiq service) | Number of simultaneously processed background jobs, default is 10 | | REVERSE_GEOCODING_ENABLED | `true` or `false`, this env var allows you to disable reverse geocoding feature entirely | +| PHOTON_API_HOST | Photon reverse geocoding api host. Useful, if you're running your own Photon instance | ## Star History diff --git a/app/models/place.rb b/app/models/place.rb index e2b24658..ac07aad0 100644 --- a/app/models/place.rb +++ b/app/models/place.rb @@ -15,7 +15,6 @@ class Place < ApplicationRecord def async_reverse_geocode return unless REVERSE_GEOCODING_ENABLED - # If place is successfully reverse geocoded, try to add it to corresponding visits as suggested ReverseGeocodingJob.perform_later(self.class.to_s, id) end diff --git a/app/models/visit.rb b/app/models/visit.rb index 4f254135..53bf4c7d 100644 --- a/app/models/visit.rb +++ b/app/models/visit.rb @@ -30,14 +30,13 @@ class Visit < ApplicationRecord end def center - area.present? ? [area.latitude, area.longitude] : [place.latitude, place.longitude] + area.present? ? area.to_coordinates : place.to_coordinates end def async_reverse_geocode return unless REVERSE_GEOCODING_ENABLED return if place.blank? - # If place is successfully reverse geocoded, try to add it to corresponding visits as suggested ReverseGeocodingJob.perform_later('place', place_id) end end diff --git a/app/services/visits/prepare.rb b/app/services/visits/prepare.rb index 21f8f753..f22aa44e 100644 --- a/app/services/visits/prepare.rb +++ b/app/services/visits/prepare.rb @@ -29,7 +29,7 @@ class Visits::Prepare def calculate_radius(center_point, group) max_distance = group.map { |point| center_point.distance_to(point) }.max - (max_distance / 10.0).ceil * 10 + max_distance.to_f.ceil end def prepare_day_result(grouped_points) diff --git a/app/views/visits/_visit.html.erb b/app/views/visits/_visit.html.erb index d1f08f37..0c62f68d 100644 --- a/app/views/visits/_visit.html.erb +++ b/app/views/visits/_visit.html.erb @@ -5,7 +5,7 @@
<%= "#{visit.started_at.strftime('%H:%M')} - #{visit.ended_at.strftime('%H:%M')}" %>
- <%= render 'visits/buttons', visit: visit if visit.suggested? %> + <%= render 'visits/buttons', visit: visit %> diff --git a/app/views/visits/index.html.erb b/app/views/visits/index.html.erb index 6125b4da..7ba8129e 100644 --- a/app/views/visits/index.html.erb +++ b/app/views/visits/index.html.erb @@ -23,6 +23,21 @@
+ + <% if @visits.empty? %>
diff --git a/docker-compose.yml b/docker-compose.yml index ad256097..895c0c9f 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -49,7 +49,6 @@ services: APPLICATION_HOSTS: localhost TIME_ZONE: Europe/London APPLICATION_PROTOCOL: http - PHOTON_API_HOST: '' logging: driver: "json-file" options: @@ -82,7 +81,6 @@ services: APPLICATION_HOSTS: localhost BACKGROUND_PROCESSING_CONCURRENCY: 10 APPLICATION_PROTOCOL: http - PHOTON_API_HOST: '' logging: driver: "json-file" options: diff --git a/spec/factories/place_visits.rb b/spec/factories/place_visits.rb index 7970b7b6..e245d5fa 100644 --- a/spec/factories/place_visits.rb +++ b/spec/factories/place_visits.rb @@ -1,6 +1,8 @@ +# frozen_string_literal: true + FactoryBot.define do factory :place_visit do - place { nil } - visit { nil } + place + visit end end diff --git a/spec/services/visits/group_spec.rb b/spec/services/visits/group_spec.rb index b6e1c373..f9726243 100644 --- a/spec/services/visits/group_spec.rb +++ b/spec/services/visits/group_spec.rb @@ -24,7 +24,7 @@ RSpec.describe Visits::Group do build(:point, latitude: 0.00007, longitude: 0.00007, timestamp: 1.day.ago + 35.minutes), build(:point, latitude: 0.00008, longitude: 0.00008, timestamp: 1.day.ago + 40.minutes), build(:point, latitude: 0.00009, longitude: 0.00009, timestamp: 1.day.ago + 45.minutes), - build(:point, latitude: 0.0001, longitude: 0.0001, timestamp: 1.day.ago + 50.minutes), + build(:point, latitude: 0.0001, longitude: 0.0001, timestamp: 1.day.ago + 50.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 55.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 95.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes), diff --git a/spec/services/visits/prepare_spec.rb b/spec/services/visits/prepare_spec.rb index f4dde1bb..3cc4be20 100644 --- a/spec/services/visits/prepare_spec.rb +++ b/spec/services/visits/prepare_spec.rb @@ -16,7 +16,7 @@ RSpec.describe Visits::Prepare do build(:point, latitude: 0.00007, longitude: 0.00007, timestamp: 1.day.ago + 35.minutes), build(:point, latitude: 0.00008, longitude: 0.00008, timestamp: 1.day.ago + 40.minutes), build(:point, latitude: 0.00009, longitude: 0.00009, timestamp: 1.day.ago + 45.minutes), - build(:point, latitude: 0.0001, longitude: 0.0001, timestamp: 1.day.ago + 50.minutes), + build(:point, latitude: 0.0001, longitude: 0.0001, timestamp: 1.day.ago + 50.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 55.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 95.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes),