| DATE(...) seems to be slightly faster than DATE_FORMAT(...) on MYSQL - reportab… | |
| Log | |
| Files | |
| Refs | |
| README | |
| --- | |
| commit b026d0c5c59126e57f28e5405c04c9505671a955 | |
| parent 22209f004c013566cbd6aa6acb167dd6b9950771 | |
| Author: Marco Otte-Witte <[email protected]> | |
| Date: Thu, 11 Mar 2010 22:02:55 +0100 | |
| DATE(...) seems to be slightly faster than DATE_FORMAT(...) on MYSQL | |
| Diffstat: | |
| M lib/saulabs/reportable/grouping.rb | 4 ++-- | |
| M spec/classes/grouping_spec.rb | 2 +- | |
| 2 files changed, 3 insertions(+), 3 deletions(-) | |
| --- | |
| diff --git a/lib/saulabs/reportable/grouping.rb b/lib/saulabs/reportable/groupi… | |
| @@ -66,7 +66,7 @@ module Saulabs | |
| if @identifier == :week | |
| parts = [db_string[0..3], db_string[4..5]].map(&:to_i) | |
| else | |
| - db_string.split('/').map(&:to_i) | |
| + db_string.split(@identifier == :day ? '-' : '/').map(&:to_i) | |
| end | |
| end | |
| @@ -99,7 +99,7 @@ module Saulabs | |
| when :hour | |
| "DATE_FORMAT(#{date_column}, '%Y/%m/%d/%H')" | |
| when :day | |
| - "DATE_FORMAT(#{date_column}, '%Y/%m/%d')" | |
| + "DATE(#{date_column})" | |
| when :week | |
| "YEARWEEK(#{date_column}, 3)" | |
| when :month | |
| diff --git a/spec/classes/grouping_spec.rb b/spec/classes/grouping_spec.rb | |
| @@ -23,7 +23,7 @@ describe Saulabs::Reportable::Grouping do | |
| end | |
| it 'should use DATE_FORMAT with format string "%Y/%m/%d" for grouping :d… | |
| - Saulabs::Reportable::Grouping.new(:day).send(:to_sql, 'created_at').sh… | |
| + Saulabs::Reportable::Grouping.new(:day).send(:to_sql, 'created_at').sh… | |
| end | |
| it 'should use YEARWEEK with mode 3 for grouping :week' do |