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 module Burden
include Config::Helper include Config::Helper
def wrap(name, description, &block) def wrap(name, &block)
Wrapper.new(name, description, block).execute Wrapper.new(name, block).execute
end end
extend self extend self

View File

@ -5,7 +5,7 @@ module Burden
self.table_name = 'burden_runs' self.table_name = 'burden_runs'
attr_accessible :name, :success, :execution_time 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 end
end end

View File

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

View File

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

View File

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