mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-10 17:21:38 -05:00
Update query to use lonlat column for bounds calculation
This commit is contained in:
parent
f99319b23d
commit
e6f74fc6ab
3 changed files with 5 additions and 7 deletions
|
|
@ -97,11 +97,12 @@ class Stat < ApplicationRecord
|
|||
return nil if point_count.zero?
|
||||
|
||||
bounds_result = ActiveRecord::Base.connection.exec_query(
|
||||
"SELECT MIN(latitude) as min_lat, MAX(latitude) as max_lat,
|
||||
MIN(longitude) as min_lng, MAX(longitude) as max_lng
|
||||
"SELECT MIN(ST_Y(lonlat::geometry)) as min_lat, MAX(ST_Y(lonlat::geometry)) as max_lat,
|
||||
MIN(ST_X(lonlat::geometry)) as min_lng, MAX(ST_X(lonlat::geometry)) as max_lng
|
||||
FROM points
|
||||
WHERE user_id = $1
|
||||
AND timestamp BETWEEN $2 AND $3",
|
||||
AND timestamp BETWEEN $2 AND $3
|
||||
AND lonlat IS NOT NULL",
|
||||
'data_bounds_query',
|
||||
[user.id, start_date.to_i, end_date.to_i]
|
||||
).first
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
readonly
|
||||
class="input input-bordered join-item flex-1"
|
||||
data-sharing-modal-target="sharingLink"
|
||||
value="<%= @stat.sharing_enabled? ? public_stat_url(@stat.sharing_uuid) : '' %>" />
|
||||
value="<%= @stat.sharing_enabled? ? shared_stat_url(@stat.sharing_uuid) : '' %>" />
|
||||
<button type="button"
|
||||
class="btn btn-outline join-item"
|
||||
data-action="click->sharing-modal#copyLink">
|
||||
|
|
|
|||
|
|
@ -75,10 +75,7 @@ Rails.application.routes.draw do
|
|||
to: 'stats#update',
|
||||
as: :update_year_month_stats,
|
||||
constraints: { year: /\d{4}/, month: /\d{1,2}|all/ }
|
||||
# Public shared stats routes
|
||||
get 'shared/stats/:uuid', to: 'shared/stats#show', as: :shared_stat
|
||||
# Backward compatibility
|
||||
get 'shared/stats/:uuid', to: 'shared/stats#show', as: :public_stat
|
||||
|
||||
# Sharing management endpoint (requires auth)
|
||||
patch 'stats/:year/:month/sharing',
|
||||
|
|
|
|||
Loading…
Reference in a new issue