Skip to content

Commit

Permalink
Sort WaterEntry#recent by amount
Browse files Browse the repository at this point in the history
  • Loading branch information
janraasch committed Dec 21, 2023
1 parent 510e142 commit ea0e80a
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion rails/app/models/water_entry.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class WaterEntry < ApplicationRecord

belongs_to :user

scope :recent, -> { distinct(:amount).order(created_at: :desc).limit(3) }
scope :recent, -> { distinct(:amount).order(created_at: :desc).limit(3).sort_by(&:amount) }
scope :amounts, -> { map(&:amount).presence || [Measured::Volume.new(0, :oz)] }

measured_volume :amount
Expand Down

0 comments on commit ea0e80a

Please sign in to comment.