重かったらキャッシュ作り込めばよかろー。


On Saturday, December 21, 2013, 英吉 wrote:

> そか。じゃぁやめとこう。
>
> On Saturday, December 21, 2013, Tomohiko Himura wrote:
>
>> In app/models/record.rb:
>>
>> > @@ -10,6 +10,17 @@ def to_goal
>> >      self.weight.to_f - self.user.goal.to_f
>> >    end
>> >
>> > +  def delta
>> > +    if prev = self.previous
>> > +      self.weight.to_f - prev.weight.to_f
>> > +    end
>> > +  end
>> > +
>> > +  def previous
>> > +    date = self.target_date
>> > +    Record.where(user_id: user_id).where{ target_date < date }.first
>>
>> 飛び飛びに登録されると前後2件じゃダメな気が。
>>
>> —
>> Reply to this email directly or view it on GitHub<https://github.com/daitokai/daitokaiet/pull/25/files#r8515827>
>> .
>>
>