mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Speed up scheduling of visits suggestions job after import
This commit is contained in:
parent
a84fde553e
commit
4627ed7a6f
2 changed files with 5 additions and 5 deletions
|
|
@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
|
||||||
- Stats will now properly reflect countries and cities visited after importing new points.
|
- Stats will now properly reflect countries and cities visited after importing new points.
|
||||||
- `GET /api/v1/points will now return correct latitude and longitude values. #1502
|
- `GET /api/v1/points will now return correct latitude and longitude values. #1502
|
||||||
- Deleting an import will now trigger stats recalculation for affected months. #1789
|
- Deleting an import will now trigger stats recalculation for affected months. #1789
|
||||||
|
- Importing process should now schedule visits suggestions job a lot faster.
|
||||||
|
|
||||||
## Changed
|
## Changed
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -78,12 +78,11 @@ class Imports::Create
|
||||||
def schedule_visit_suggesting(user_id, import)
|
def schedule_visit_suggesting(user_id, import)
|
||||||
return unless user.safe_settings.visits_suggestions_enabled?
|
return unless user.safe_settings.visits_suggestions_enabled?
|
||||||
|
|
||||||
points = import.points.order(:timestamp)
|
min_max = import.points.pluck('MIN(timestamp), MAX(timestamp)').first
|
||||||
|
return if min_max.compact.empty?
|
||||||
|
|
||||||
return if points.none?
|
start_at = Time.zone.at(min_max[0])
|
||||||
|
end_at = Time.zone.at(min_max[1])
|
||||||
start_at = Time.zone.at(points.first.timestamp)
|
|
||||||
end_at = Time.zone.at(points.last.timestamp)
|
|
||||||
|
|
||||||
VisitSuggestingJob.perform_later(user_id:, start_at:, end_at:)
|
VisitSuggestingJob.perform_later(user_id:, start_at:, end_at:)
|
||||||
end
|
end
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue