Skip to content

Commit

Permalink
Filter unique amounts on the app level
Browse files Browse the repository at this point in the history
  • Loading branch information
janraasch committed Dec 22, 2023
1 parent cc9481f commit 7c85026
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).sort_by(&:amount) }
scope :recent, -> { order(created_at: :desc).limit(3).uniq(&:amount_value).sort_by(&:amount) }
scope :amounts, -> { map(&:amount).presence || [Measured::Volume.new(0, :oz)] }

measured_volume :amount
Expand Down

0 comments on commit 7c85026

Please sign in to comment.