Skip to content

Instantly share code, notes, and snippets.

@squeejee
Created May 18, 2009 02:57
Show Gist options
  • Save squeejee/113285 to your computer and use it in GitHub Desktop.
Save squeejee/113285 to your computer and use it in GitHub Desktop.
class Entry < ActiveRecord::Base
named_scope :by_date, lambda { |*args|
{
:order => "starts_at asc",
:conditions => ["starts_at BETWEEN ? AND ?", args[0].beginning_of_day.to_s(:db), (args[1]||Time.now).end_of_day.to_s(:db)]
} } do
def duration_by_project
self.sum(:duration, :group => :project)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment