- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
(Time.now.to_date-1.year .. Time.now.to_date).
map{|x| {x.to_time.to_i =>0} }.
reduce(Hash.new, :merge).merge(
TrackLocation.unscoped.joins(:track).where(track: @user.all_tracks).
where("tracks.start_time < ? AND tracks.start_time > ?", Time.now.to_date, Time.now.to_date-1.year).
group(:start_time).maximum(:distance).
map{|x,v| {x.to_date.to_time.to_i => v.round(3)} if v}.compact.
reduce(Hash.new, :merge)
)
Follow us!