rgviz-rails 0.16 → 0.17

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -205,18 +205,17 @@ module Rgviz
205
205
  grouped_by << val
206
206
  elsif @pivots.include?(@original_columns[i])
207
207
  pivots << val
208
- uniq_pivots << val unless uniq_pivots.include? val
209
208
  else
210
209
  selections << val
211
210
  end
212
211
  end
213
212
 
213
+ uniq_pivots << pivots unless uniq_pivots.include? pivots
214
+
214
215
  # Now put all this info into fin
215
216
  fin[grouped_by] = {} unless fin[grouped_by]
216
- pivots.each do |pivot|
217
- selections.each do |selection|
218
- fin[grouped_by][pivot] = selection
219
- end
217
+ selections.each do |selection|
218
+ fin[grouped_by][pivots] = selection
220
219
  end
221
220
  end
222
221
 
@@ -235,7 +234,7 @@ module Rgviz
235
234
  col_i += 1
236
235
  elsif !@pivots.include?(original_column)
237
236
  uniq_pivots.each do |uniq_pivot|
238
- new_cols << (Column.new :id => "c#{col_i}", :type => old_col.type, :label => "#{uniq_pivot} #{old_col.label}")
237
+ new_cols << (Column.new :id => "c#{col_i}", :type => old_col.type, :label => "#{uniq_pivot.join(', ')} #{old_col.label}")
239
238
  col_i += 1
240
239
  end
241
240
  end
@@ -350,4 +350,22 @@ describe Executor do
350
350
  end
351
351
  end
352
352
 
353
+ it "processes pivot3" do
354
+ Person.make :name => 'Eng', :birthday => '2000-01-12', :age => 10
355
+ Person.make :name => 'Eng', :birthday => '2001-02-12', :age => 10
356
+
357
+ table = exec 'select name, sum(age) group by name pivot year(birthday), month(birthday)'
358
+
359
+ table.cols.length.should == 3
360
+
361
+ i = 0
362
+ [['Eng', 10, 10]].each do |values|
363
+ table.rows[i].c.length.should == 3
364
+ values.each_with_index do |v, j|
365
+ table.rows[i].c[j].v.should == v
366
+ end
367
+ i += 1
368
+ end
369
+ end
370
+
353
371
  end
data/spec/spec_helper.rb CHANGED
@@ -6,8 +6,8 @@ require 'logger'
6
6
 
7
7
  require 'active_record'
8
8
 
9
- #ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
10
- ActiveRecord::Base.establish_connection(:adapter => 'mysql', :database => 'rgviz_rails', :username => 'root', :password => 'Manas.03')
9
+ ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
10
+ #ActiveRecord::Base.establish_connection(:adapter => 'mysql', :database => 'rgviz_rails', :username => 'root', :password => 'Manas.03')
11
11
 
12
12
  ActiveRecord::Schema.define do
13
13
  create_table "cities", :force => true do |t|
metadata CHANGED
@@ -1,12 +1,12 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rgviz-rails
3
3
  version: !ruby/object:Gem::Version
4
- hash: 43
4
+ hash: 41
5
5
  prerelease: false
6
6
  segments:
7
7
  - 0
8
- - 16
9
- version: "0.16"
8
+ - 17
9
+ version: "0.17"
10
10
  platform: ruby
11
11
  authors:
12
12
  - Ary Borenszweig