Updates here and there

This commit is contained in:
Eugene Burmakin 2024-08-25 20:48:00 +02:00
parent 7d7005063b
commit ace93f7534
12 changed files with 30 additions and 24 deletions

View file

@ -1 +1 @@
0.11.2 0.12.0

View file

@ -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/) The format is based on [Keep a Changelog](http://keepachangelog.com/)
and this project adheres to [Semantic Versioning](http://semver.org/). and this project adheres to [Semantic Versioning](http://semver.org/).
## [Unreleased] ## [0.12.0] — 2024-08-25
The visit suggestion release. 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. 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. 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 ### 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 - 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 - 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 - 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 ## [0.11.2] — 2024-08-22

View file

@ -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` | | 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 | | 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 | | 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 ## Star History

View file

@ -15,7 +15,6 @@ class Place < ApplicationRecord
def async_reverse_geocode def async_reverse_geocode
return unless REVERSE_GEOCODING_ENABLED 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) ReverseGeocodingJob.perform_later(self.class.to_s, id)
end end

View file

@ -30,14 +30,13 @@ class Visit < ApplicationRecord
end end
def center def center
area.present? ? [area.latitude, area.longitude] : [place.latitude, place.longitude] area.present? ? area.to_coordinates : place.to_coordinates
end end
def async_reverse_geocode def async_reverse_geocode
return unless REVERSE_GEOCODING_ENABLED return unless REVERSE_GEOCODING_ENABLED
return if place.blank? 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) ReverseGeocodingJob.perform_later('place', place_id)
end end
end end

View file

@ -29,7 +29,7 @@ class Visits::Prepare
def calculate_radius(center_point, group) def calculate_radius(center_point, group)
max_distance = group.map { |point| center_point.distance_to(point) }.max max_distance = group.map { |point| center_point.distance_to(point) }.max
(max_distance / 10.0).ceil * 10 max_distance.to_f.ceil
end end
def prepare_day_result(grouped_points) def prepare_day_result(grouped_points)

View file

@ -5,7 +5,7 @@
<div><%= "#{visit.started_at.strftime('%H:%M')} - #{visit.ended_at.strftime('%H:%M')}" %></div> <div><%= "#{visit.started_at.strftime('%H:%M')} - #{visit.ended_at.strftime('%H:%M')}" %></div>
</div> </div>
<div class="opacity-0 transition-opacity duration-200 group-hover:opacity-100 flex items-center ml-4"> <div class="opacity-0 transition-opacity duration-200 group-hover:opacity-100 flex items-center ml-4">
<%= render 'visits/buttons', visit: visit if visit.suggested? %> <%= render 'visits/buttons', visit: visit %>
<!-- The button to open modal --> <!-- The button to open modal -->
<label for="visit_details_popup_<%= visit.id %>" class='btn btn-xs btn-info'>Map</label> <label for="visit_details_popup_<%= visit.id %>" class='btn btn-xs btn-info'>Map</label>

View file

@ -23,6 +23,21 @@
</div> </div>
</div> </div>
<div role="alert" class="alert">
<svg
xmlns="http://www.w3.org/2000/svg"
fill="none"
viewBox="0 0 24 24"
class="stroke-info h-6 w-6 shrink-0">
<path
stroke-linecap="round"
stroke-linejoin="round"
stroke-width="2"
d="M13 16h-1v-4h-1m1-4h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
</svg>
<span>Visits suggestion feature is currently in beta stage. Expect bugs and problems and don't hesitate to report them to <a href='https://github.com/Freika/dawarich/issues' class='link'>Github Issues</a>.</span>
</div>
<% if @visits.empty? %> <% if @visits.empty? %>
<div class="hero min-h-80 bg-base-200"> <div class="hero min-h-80 bg-base-200">
<div class="hero-content text-center"> <div class="hero-content text-center">

View file

@ -49,7 +49,6 @@ services:
APPLICATION_HOSTS: localhost APPLICATION_HOSTS: localhost
TIME_ZONE: Europe/London TIME_ZONE: Europe/London
APPLICATION_PROTOCOL: http APPLICATION_PROTOCOL: http
PHOTON_API_HOST: ''
logging: logging:
driver: "json-file" driver: "json-file"
options: options:
@ -82,7 +81,6 @@ services:
APPLICATION_HOSTS: localhost APPLICATION_HOSTS: localhost
BACKGROUND_PROCESSING_CONCURRENCY: 10 BACKGROUND_PROCESSING_CONCURRENCY: 10
APPLICATION_PROTOCOL: http APPLICATION_PROTOCOL: http
PHOTON_API_HOST: ''
logging: logging:
driver: "json-file" driver: "json-file"
options: options:

View file

@ -1,6 +1,8 @@
# frozen_string_literal: true
FactoryBot.define do FactoryBot.define do
factory :place_visit do factory :place_visit do
place { nil } place
visit { nil } visit
end end
end end

View file

@ -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.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.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.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 + 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 + 95.minutes),
build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes),

View file

@ -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.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.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.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 + 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 + 95.minutes),
build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes), build(:point, latitude: 0.00011, longitude: 0.00011, timestamp: 1.day.ago + 100.minutes),