cleaned up Grouping - reportable - Unnamed repository; edit this file 'descript… | |
Log | |
Files | |
Refs | |
README | |
--- | |
commit f9df5dd39ba665417bbfb88a42950fc2ad4ba78e | |
parent bbd76660d6b48d0a91aac63178aaa72b95d1a9d3 | |
Author: marcoow <[email protected]> | |
Date: Fri, 12 Dec 2008 01:46:59 +0800 | |
cleaned up Grouping | |
Signed-off-by: Marco Otte-Witte <[email protected]> | |
Diffstat: | |
M Rakefile | 4 ++-- | |
M lib/kvlr/reports_as_sparkline/grou… | 25 ++++++++++++------------- | |
2 files changed, 14 insertions(+), 15 deletions(-) | |
--- | |
diff --git a/Rakefile b/Rakefile | |
@@ -1,10 +1,10 @@ | |
require 'rake' | |
require 'rake/rdoctask' | |
require 'spec/rake/spectask' | |
- | |
+ | |
desc 'Default: run specs.' | |
task :default => :spec | |
- | |
+ | |
desc 'Run the specs' | |
Spec::Rake::SpecTask.new(:spec) do |t| | |
t.spec_opts = ['-cfs'] | |
diff --git a/lib/kvlr/reports_as_sparkline/grouping.rb b/lib/kvlr/reports_as_sp… | |
@@ -15,23 +15,22 @@ module Kvlr #:nodoc: | |
def date_parts_from_db_string(db_string) | |
if ActiveRecord::Base.connection.class.to_s == 'ActiveRecord::Connecti… | |
- if @identifier == :hour | |
- return (db_string[0..9].split('-') + [db_string[11..12]]).map(&:to… | |
- elsif @identifier == :day | |
- return db_string[0..9].split('-').map(&:to_i) | |
- elsif @identifier == :week | |
- parts = db_string[0..9].split('-').map(&:to_i) | |
- date = Date.new(parts[0], parts[1], parts[2]) | |
- return [date.year, date.cweek] | |
- elsif @identifier == :month | |
- return db_string[0..6].split('-')[0..1].map(&:to_i) | |
+ case @identifier | |
+ when :hour | |
+ return (db_string[0..9].split('-') + [db_string[11..12]]).map(&:… | |
+ when :day | |
+ return db_string[0..9].split('-').map(&:to_i) | |
+ when :week | |
+ parts = db_string[0..9].split('-').map(&:to_i) | |
+ date = Date.new(parts[0], parts[1], parts[2]) | |
+ return [date.year, date.cweek] | |
+ when :month | |
+ return db_string[0..6].split('-')[0..1].map(&:to_i) | |
end | |
else | |
parts = db_string.split('/').map(&:to_i) | |
return parts if ActiveRecord::Base.connection.class.to_s == 'ActiveR… | |
- if @identifier == :week | |
- parts[1] += 1 | |
- end | |
+ parts[1] += 1 if @identifier == :week | |
parts | |
end | |
end |