Displaying 1 result from an estimated 1 matches for "weighted_tot".
Did you mean:
weighted_total
2006 Nov 06
2
Shouldn't ranges work for datetime fields
I figure ranges should work just fine for a datetime. I want to weight
a total based on how recently an item was created. Using the case
statement, I check various ranges. I simply cannot get this to work:
weighted_total +=
case item.created_at
when Time.now...24.hours.ago: 20
when 24.hours.ago...48.hours.ago: 8
when 48.hours.ago...1.week.ago: 4
when 1.week.ago...2.weeks.ago: 2
when 2.weeks.ago...4.weeks.ago: 1
else...