forest_liana 2.5.4 → 2.5.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ffa19543c4688c771f14aec5ae9ebdabdc7085d7
4
- data.tar.gz: 4d871b809392f7f2590daf1b101e1a3646de7383
3
+ metadata.gz: 5214128ae98854ef7c971f1dcab51b1ccaf4ed42
4
+ data.tar.gz: aa5a5656d07a4156fdf6bd486436c01e93abf23e
5
5
  SHA512:
6
- metadata.gz: ec682fb2e85cf9adb6c90567b93712834f8927eecded2dcd3790a357106687342f9fa2f04350f456395336d7ec31e7b10a09355205dfdaf31758c4837bec6b28
7
- data.tar.gz: 7b97a495d06d1eb3017012a830aed7e2bfed0673259c5d2ce189173241ae3e17aa5bcfe8cb91aa84114bfabf8b011f4c074680e088759c09bf845fd327a9e492
6
+ metadata.gz: 4465170c5c167630fb5a6cd90c2b723219f375c9b34ed0163cc6cd0b54f417793c4692ca1134d88ee46f482d8d071daae182850487ec99be847061a481a07d78
7
+ data.tar.gz: '0322564698c541a518da0c69aa8138f4b9733ea5906624d9458cbfe030d0bfcbc9f05d34c4551a4e60a1bdd515435f78df7e9ab631007b307dd9cc666ba812e2'
@@ -1,5 +1,7 @@
1
1
  module ForestLiana
2
2
  module AdapterHelper
3
+ ADAPTER_MYSQL2 = 'Mysql2'
4
+
3
5
  def self.format_column_name(table_name, column_name)
4
6
  quoted_table_name = ActiveRecord::Base.connection.quote_table_name(table_name)
5
7
  quoted_column_name = ActiveRecord::Base.connection.quote_column_name(column_name)
@@ -13,5 +15,35 @@ module ForestLiana
13
15
  value
14
16
  end
15
17
  end
18
+
19
+ def self.format_live_query_value_result(result)
20
+ # NOTICE: The adapters have their own specific format for the live query value chart results.
21
+ case ActiveRecord::Base.connection.adapter_name
22
+ when ADAPTER_MYSQL2
23
+ { 'value' => result.first.first }
24
+ else
25
+ result.first
26
+ end
27
+ end
28
+
29
+ def self.format_live_query_pie_result(result)
30
+ # NOTICE: The adapters have their own specific format for the live query pie chart results.
31
+ case ActiveRecord::Base.connection.adapter_name
32
+ when ADAPTER_MYSQL2
33
+ result.map { |value| { 'key' => value[0], 'value' => value[1] } }
34
+ else
35
+ result.to_a
36
+ end
37
+ end
38
+
39
+ def self.format_live_query_line_result(result)
40
+ # NOTICE: The adapters have their own specific format for the live query line chart results.
41
+ case ActiveRecord::Base.connection.adapter_name
42
+ when ADAPTER_MYSQL2
43
+ result.map { |value| { 'key' => value[0], 'value' => value[1] } }
44
+ else
45
+ result
46
+ end
47
+ end
16
48
  end
17
49
  end
@@ -22,7 +22,7 @@ module ForestLiana
22
22
  case @params['type']
23
23
  when 'Value'
24
24
  if result.count
25
- result_line = result.first
25
+ result_line = ForestLiana::AdapterHelper.format_live_query_value_result(result)
26
26
  if result_line
27
27
  if !result_line.key?('value')
28
28
  raise error_message(result_line, "'value'")
@@ -38,23 +38,27 @@ module ForestLiana
38
38
  end
39
39
  when 'Pie'
40
40
  if result.count
41
- result.each do |result_line|
41
+ values = ForestLiana::AdapterHelper.format_live_query_pie_result(result)
42
+
43
+ values.each do |result_line|
42
44
  if !result_line.key?('value') || !result_line.key?('key')
43
45
  raise error_message(result_line, "'key', 'value'")
44
46
  end
45
47
  end
46
48
 
47
- @record = Model::Stat.new(value: result.to_a)
49
+ @record = Model::Stat.new(value: values)
48
50
  end
49
51
  when 'Line'
50
52
  if result.count
51
- result.each do |result_line|
53
+ values = ForestLiana::AdapterHelper.format_live_query_line_result(result)
54
+
55
+ values.each do |result_line|
52
56
  if !result_line.key?('value') || !result_line.key?('key')
53
57
  raise error_message(result_line, "'key', 'value'")
54
58
  end
55
59
  end
56
60
 
57
- result_formatted = result.map do |result_line|
61
+ result_formatted = values.map do |result_line|
58
62
  { label: result_line['key'], values: { value: result_line['value'] }}
59
63
  end
60
64
 
@@ -1,3 +1,3 @@
1
1
  module ForestLiana
2
- VERSION = "2.5.4"
2
+ VERSION = "2.5.5"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: forest_liana
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.4
4
+ version: 2.5.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sandro Munda
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2018-05-14 00:00:00.000000000 Z
11
+ date: 2018-05-23 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails