1
0
Fork 0

Mongo scopes

This commit is contained in:
Gregory Eremin 2013-06-07 11:57:03 +04:00
parent 908d8492f7
commit 861c12aa32
5 changed files with 8 additions and 6 deletions

View File

@ -11,8 +11,8 @@ require 'burden/wrapper'
module Burden
include Config::Helper
def wrap(name, description, &block)
Wrapper.new(name, description, block).execute
def wrap(name, &block)
Wrapper.new(name, block).execute
end
extend self

View File

@ -5,7 +5,7 @@ module Burden
self.table_name = 'burden_runs'
attr_accessible :name, :success, :execution_time
scope :summary, ->{ group(:name).order('created_at desc') }
scope :summary, ->{ order('created_at desc').group(:name) }
end
end
end

View File

@ -8,6 +8,8 @@ module Burden
key :name, String
key :success, Boolean
key :execution_time, Float
scope :summary, ->{ sort(:created_at.desc).group_by(&:name) }
end
end
end

View File

@ -8,6 +8,8 @@ module Burden
field :name, type: String
field :success, type: Boolean
field :execution_time, type: Float
scope :summary, ->{ sort(created_at: -1).group_by(&:name) }
end
end
end

View File

@ -3,9 +3,7 @@ module Rake
alias_method :original_execute, :execute
def execute(args)
Burden.wrap(name, comment) do
original_execute(args)
end
Burden.wrap(name){ original_execute(args) }
end
end
end