sum of points for last seven days

Hey guys,

im very very stuck trying to figure out how to go about implementing a
sum method to sum up the points a user gained for each day of the
week.

schema:
  create_table "user_point_logs", :force => true do |t|
    t.column "user_id", :integer
    t.column "points", :integer
    t.column "created_at", :datetime
  end

I want to be about to simply calculate the total points the user
gained for the last seven days.

I got this so far.
controller:
    @statistics = @current_user.user_point_logs.find(:all,
      :conditions => ['created_at > ?', 7.days.ago])

view:
   @statistics.sum(&:points)

can any provided me some snippets to help me out?

regards,

Chubbs

i made some improve if anyone can improve on it more to help me,

i got this so far

@stats = @current_user.user_point_logs.sum(:points, :group =>
'created_at')

but i want to fine tune it to work only for the last 7 days

no worries !!

thanks all good, worked it out

for your interests..

    @stats = @current_user.user_point_logs.sum(:points,
      :group => 'date(created_at)',
      :conditions => ['created_at > ?', 7.days.ago])