Introduction
Introduction Statistics Contact Development Disclaimer Help
fixed bug in handling of weeks returned from MySQL - reportable - Fork of repor…
Log
Files
Refs
README
---
commit bea3592f63f6bd00be2b31f57f56ffe4103e55df
parent d6274d2beb37b45305b19063f194f48ebe6fb766
Author: Marco Otte-Witte <[email protected]>
Date: Thu, 15 Jan 2009 01:34:20 +0800
fixed bug in handling of weeks returned from MySQL
Signed-off-by: Marco Otte-Witte <[email protected]>
Diffstat:
M lib/kvlr/reports_as_sparkline/grou… | 5 ++++-
M lib/kvlr/reports_as_sparkline/repo… | 2 +-
M spec/classes/grouping_spec.rb | 8 ++++----
3 files changed, 9 insertions(+), 6 deletions(-)
---
diff --git a/lib/kvlr/reports_as_sparkline/grouping.rb b/lib/kvlr/reports_as_sp…
@@ -34,7 +34,10 @@ module Kvlr #:nodoc:
else
parts = db_string.split('/').map(&:to_i)
return parts if ActiveRecord::Base.connection.class.to_s == 'ActiveR…
- parts[1] += 1 if @identifier == :week
+ if @identifier == :week && parts[1] > 52
+ parts[0] += 1
+ parts[1] = 1
+ end
parts
end
end
diff --git a/lib/kvlr/reports_as_sparkline/reporting_period.rb b/lib/kvlr/repor…
@@ -43,7 +43,7 @@ module Kvlr #:nodoc:
when :day
self.new(grouping, Date.new(parts[0], parts[1], parts[2]))
when :week
- self.new(grouping, Date.commercial(parts[0], parts[1]))
+ self.new(grouping, Date.commercial(parts[0], parts[1], 1))
when :month
self.new(grouping, Date.new(parts[0], parts[1], 1))
end
diff --git a/spec/classes/grouping_spec.rb b/spec/classes/grouping_spec.rb
@@ -86,7 +86,7 @@ describe Kvlr::ReportsAsSparkline::Grouping do
ActiveRecord::Base.connection.stub!(:class).and_return(ActiveRecord::C…
end
- for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month…
+ for grouping in [[:hour, '2008/12/31/12'], [:day, '2008/12/31'], [:month…
it "should split the string with '/' for grouping :#{grouping[0].to_s}…
Kvlr::ReportsAsSparkline::Grouping.new(grouping[0]).date_parts_from_…
@@ -94,9 +94,9 @@ describe Kvlr::ReportsAsSparkline::Grouping do
end
- it 'should split the string with "/" and increment the week by 1 for gro…
- db_string = '2008/2'
- expected = [2008, 3]
+ it 'should split the string with "/", set the week to 1 and increment th…
+ db_string = '2008/53'
+ expected = [2009, 1]
Kvlr::ReportsAsSparkline::Grouping.new(:week).date_parts_from_db_strin…
end
You are viewing proxied material from jay.scot. The copyright of proxied material belongs to its original authors. Any comments or complaints in relation to proxied material should be directed to the original authors of the content concerned. Please see the disclaimer for more details.