mirror of
https://github.com/Freika/dawarich.git
synced 2026-01-11 09:41:40 -05:00
Fix year page charts
This commit is contained in:
parent
b7e5296235
commit
0295d3f2a0
5 changed files with 12 additions and 24 deletions
|
|
@ -66,20 +66,6 @@ class Point < ApplicationRecord
|
|||
Country.containing_point(lon, lat)
|
||||
end
|
||||
|
||||
def self.normalize_timestamp(timestamp)
|
||||
case timestamp
|
||||
when Integer
|
||||
timestamp
|
||||
when String, Numeric, DateTime, Time
|
||||
timestamp.to_i
|
||||
when nil
|
||||
raise ArgumentError, 'Timestamp cannot be nil'
|
||||
else
|
||||
raise ArgumentError, "Cannot convert timestamp to integer: #{timestamp.class}"
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
# rubocop:disable Metrics/MethodLength Metrics/AbcSize
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ class Stat < ApplicationRecord
|
|||
timespan.to_a.map.with_index(1) do |day, index|
|
||||
daily_points = filter_points_for_day(monthly_points, day)
|
||||
# Calculate distance in meters for consistent storage
|
||||
distance_meters = Point.total_distance(daily_points, :m)
|
||||
distance_meters = Point.total_distance(daily_points, :km)
|
||||
[index, distance_meters.round]
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ class Immich::ImportGeodata
|
|||
latitude: asset['exifInfo']['latitude'],
|
||||
longitude: asset['exifInfo']['longitude'],
|
||||
lonlat: "SRID=4326;POINT(#{asset['exifInfo']['longitude']} #{asset['exifInfo']['latitude']})",
|
||||
timestamp: Point.normalize_timestamp(asset['exifInfo']['dateTimeOriginal'])
|
||||
timestamp: Time.zone.parse(asset['exifInfo']['dateTimeOriginal']).to_i
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ class Photoprism::ImportGeodata
|
|||
latitude: asset['Lat'],
|
||||
longitude: asset['Lng'],
|
||||
lonlat: "SRID=4326;POINT(#{asset['Lng']} #{asset['Lat']})",
|
||||
timestamp: Point.normalize_timestamp(asset['TakenAt'])
|
||||
timestamp: Time.zone.parse(asset['TakenAt']).to_i
|
||||
}
|
||||
end
|
||||
|
||||
|
|
|
|||
|
|
@ -18,11 +18,13 @@
|
|||
<%= countries_and_cities_stat_for_month(stat) %>
|
||||
</div>
|
||||
|
||||
<canvas id="distance-chart-<%= stat.id %>"
|
||||
data-daily-distance="<%= stat.daily_distance %>"
|
||||
data-distance-type="monthly"
|
||||
data-title="<%= Date::MONTHNAMES[stat.month] %> <%= stat.year %>"
|
||||
data-y-axis-title="Distance"
|
||||
suffix: " <%= current_user.safe_settings.distance_unit %>",
|
||||
data-user-settings="<%= current_user.safe_settings.default_settings.to_json %>"></canvas>
|
||||
<%= area_chart(
|
||||
stat.daily_distance.map { |day, distance_meters|
|
||||
[day, Stat.convert_distance(distance_meters, current_user.safe_settings.distance_unit).round(2)]
|
||||
},
|
||||
height: '200px',
|
||||
suffix: " #{current_user.safe_settings.distance_unit}",
|
||||
xtitle: 'Day',
|
||||
ytitle: 'Distance'
|
||||
) %>
|
||||
</div>
|
||||
|
|
|
|||
Loading…
Reference in a new issue