From 861c12aa32a1e4aadb88c8830a9fc4ab86a42941 Mon Sep 17 00:00:00 2001 From: Gregory Eremin Date: Fri, 7 Jun 2013 11:57:03 +0400 Subject: [PATCH] Mongo scopes --- lib/burden.rb | 4 ++-- lib/burden/storage/active_record/run.rb | 2 +- lib/burden/storage/mongo_mapper/run.rb | 2 ++ lib/burden/storage/mongoid/run.rb | 2 ++ lib/rake/task.rb | 4 +--- 5 files changed, 8 insertions(+), 6 deletions(-) diff --git a/lib/burden.rb b/lib/burden.rb index eb4c103..28ce375 100644 --- a/lib/burden.rb +++ b/lib/burden.rb @@ -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 diff --git a/lib/burden/storage/active_record/run.rb b/lib/burden/storage/active_record/run.rb index 51e60c9..a6d29b9 100644 --- a/lib/burden/storage/active_record/run.rb +++ b/lib/burden/storage/active_record/run.rb @@ -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 diff --git a/lib/burden/storage/mongo_mapper/run.rb b/lib/burden/storage/mongo_mapper/run.rb index 7db50e9..5c491a6 100644 --- a/lib/burden/storage/mongo_mapper/run.rb +++ b/lib/burden/storage/mongo_mapper/run.rb @@ -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 diff --git a/lib/burden/storage/mongoid/run.rb b/lib/burden/storage/mongoid/run.rb index 2568860..517d035 100644 --- a/lib/burden/storage/mongoid/run.rb +++ b/lib/burden/storage/mongoid/run.rb @@ -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 diff --git a/lib/rake/task.rb b/lib/rake/task.rb index 9d5d73b..ea2d87e 100644 --- a/lib/rake/task.rb +++ b/lib/rake/task.rb @@ -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