lib/saulabs/reportable/grouping.rb in reportable-1.0.3 vs lib/saulabs/reportable/grouping.rb in reportable-1.1.0
- old
+ new
@@ -64,11 +64,11 @@
def from_mysql_db_string(db_string)
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
def from_sqlite_db_string(db_string)
if @identifier == :week
@@ -97,10 +97,10 @@
def mysql_format(date_column)
case @identifier
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
"DATE_FORMAT(#{date_column}, '%Y/%m')"
end