activecube-graphql 0.1.1 → 0.1.2

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 992470f7a32c278749b214f1ca73dece8ec582286fcc97d379b16a7f1775b455
4
- data.tar.gz: df5e4a79dff0740f6c37b3e08a7ebec7b73fd214c41b70b9a46c78d2fad1d13c
3
+ metadata.gz: 80f8414694cc16fa1db6913ad933d52f60878aafe90ba54ca6cc4be1d45afa93
4
+ data.tar.gz: ae5c10601123efac43763ed74fd9560e175af8cef858f7450f9e5b0ed4375a02
5
5
  SHA512:
6
- metadata.gz: 223daebf247315236a08e766250661dcbf6d09891b2993c40f059b626b0a7ad23757b3fae948419259ea01235d7ee0f3e3c6407b587217a38d8efeef06bddbe3
7
- data.tar.gz: d4d084eb7d84489972e03fdde6bf715e25ff85d5e825cfd0de5af998bad72127dc7f35fa779b20d3925b760966d984b16ecc0b70601bf8440f0cfee9deae36b5
6
+ metadata.gz: 32e56685b2f44640f6636aaf1ceff09178a575bdd58103204a032e9d96c9b355c15ef156c34ca8ac240d24b57ba2ff734e97dca416bc6ae72416f3211f09af48
7
+ data.tar.gz: fca9fe6ebce5a9c7f48d47f9cf787615367e6c85660daa4d2986e1b3e48df4f7ca092230edeacc156cc402350de675d044441ebeabbb2c327977e9e4054af599
@@ -11,14 +11,13 @@
11
11
  </content>
12
12
  <orderEntry type="jdk" jdkName="RVM: ruby-2.6.3" jdkType="RUBY_SDK" />
13
13
  <orderEntry type="sourceFolder" forTests="false" />
14
- <orderEntry type="library" scope="PROVIDED" name="activecube (v0.1.3, RVM: ruby-2.6.3) [gem]" level="application" />
15
14
  <orderEntry type="library" scope="PROVIDED" name="activemodel (v6.0.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
16
15
  <orderEntry type="library" scope="PROVIDED" name="activerecord (v6.0.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
17
16
  <orderEntry type="library" scope="PROVIDED" name="activesupport (v6.0.2.1, RVM: ruby-2.6.3) [gem]" level="application" />
18
17
  <orderEntry type="library" scope="PROVIDED" name="bundler (v1.17.3, RVM: ruby-2.6.3) [gem]" level="application" />
19
18
  <orderEntry type="library" scope="PROVIDED" name="concurrent-ruby (v1.1.6, RVM: ruby-2.6.3) [gem]" level="application" />
20
19
  <orderEntry type="library" scope="PROVIDED" name="diff-lcs (v1.3, RVM: ruby-2.6.3) [gem]" level="application" />
21
- <orderEntry type="library" scope="PROVIDED" name="graphql (v1.10.3, RVM: ruby-2.6.3) [gem]" level="application" />
20
+ <orderEntry type="library" scope="PROVIDED" name="graphql (v1.10.4, RVM: ruby-2.6.3) [gem]" level="application" />
22
21
  <orderEntry type="library" scope="PROVIDED" name="i18n (v1.8.2, RVM: ruby-2.6.3) [gem]" level="application" />
23
22
  <orderEntry type="library" scope="PROVIDED" name="minitest (v5.14.0, RVM: ruby-2.6.3) [gem]" level="application" />
24
23
  <orderEntry type="library" scope="PROVIDED" name="rake (v10.5.0, RVM: ruby-2.6.3) [gem]" level="application" />
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- activecube-graphql (0.1.1)
4
+ activecube-graphql (0.1.2)
5
5
  activecube (~> 0.1.3)
6
6
  graphql (~> 1.9)
7
7
 
@@ -24,7 +24,7 @@ to query cubes}
24
24
  spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
25
25
  spec.require_paths = ["lib"]
26
26
 
27
- spec.add_runtime_dependency 'activecube', '~> 0.1.3'
27
+ spec.add_runtime_dependency 'activecube', '~> 0.1.4'
28
28
  spec.add_runtime_dependency 'graphql', '~> 1.9'
29
29
 
30
30
  spec.add_development_dependency "bundler", "~> 1.17"
@@ -31,8 +31,12 @@ module Activecube
31
31
 
32
32
  database = obj.object.kind_of?(Hash) && obj.object[:database]
33
33
  response = database ? cube.connected_to(database: database) do
34
- execute_query(tree)
35
- end : execute_query(tree)
34
+ execute_query(tree, ctx)
35
+ end : execute_query(tree, ctx)
36
+
37
+ if ctx[:stat_io].respond_to?(:puts) && response.respond_to?(:statistics)
38
+ ctx[:stat_io].puts(response.statistics)
39
+ end
36
40
 
37
41
  ResponseBuilder.new tree, response
38
42
 
@@ -42,9 +46,9 @@ module Activecube
42
46
 
43
47
  private
44
48
 
45
- def execute_query tree
49
+ def execute_query tree, ctx
46
50
  cube_query = tree.build_query
47
- puts cube_query.to_sql
51
+ ctx[:sql_io].puts(cube_query.to_sql) if ctx[:sql_io].respond_to?(:puts)
48
52
  cube_query.query
49
53
  end
50
54
 
@@ -5,7 +5,7 @@ module Activecube
5
5
  class Element
6
6
 
7
7
  attr_reader :arguments, :ast_node, :cube, :parent, :name, :definition, :key,
8
- :children, :metric, :dimension, :field
8
+ :children, :metric, :dimension, :field, :context_node
9
9
  def initialize cube, context_node, parent = nil
10
10
 
11
11
  @cube = cube
@@ -14,6 +14,7 @@ module Activecube
14
14
  @name = context_node.name
15
15
  @key = parent ? (parent.key ? "#{parent.key}.#{name}" : name ) : nil
16
16
 
17
+ @context_node = context_node
17
18
  @arguments = context_node.arguments.to_h
18
19
 
19
20
  @ast_node = context_node.ast_node
@@ -45,8 +46,12 @@ module Activecube
45
46
 
46
47
  if metric
47
48
  query = query.measure({key => apply_args(metric)})
48
- elsif dimension && children.empty?
49
- query = query.slice({key => apply_args(field || dimension)})
49
+ elsif dimension
50
+ if children.empty?
51
+ query = query.slice({key => apply_args(field || dimension)})
52
+ elsif !arguments.empty?
53
+ query = apply_args query
54
+ end
50
55
  end
51
56
 
52
57
  else
@@ -9,6 +9,15 @@ module Activecube::Graphql
9
9
  @row = row
10
10
  end
11
11
 
12
+ def convert_type node_type, value
13
+ case node_type
14
+ when 'Boolean' then
15
+ value==1
16
+ else
17
+ value
18
+ end
19
+ end
20
+
12
21
  end
13
22
 
14
23
 
@@ -55,7 +64,7 @@ module Activecube::Graphql
55
64
 
56
65
  index = Hash[elements.collect { |element|
57
66
  value = if element.children.empty?
58
- @key_map[element.key]
67
+ [@key_map[element.key], element.context_node.definition.type.name]
59
68
  else
60
69
  build_response_class element
61
70
  end
@@ -67,8 +76,8 @@ module Activecube::Graphql
67
76
  key = ast_node.alias || ast_node.name
68
77
  if (value = index[key]).kind_of? Class
69
78
  value.new @row
70
- elsif value.kind_of? Integer
71
- @row[value]
79
+ elsif value.kind_of? Array
80
+ convert_type value.second, @row[value.first]
72
81
  else
73
82
  raise ArgumentError, "Unexpected request to #{definition} by key #{key}"
74
83
  end
@@ -88,14 +97,14 @@ module Activecube::Graphql
88
97
 
89
98
  def simple_value response_class, definition, element
90
99
  index = @key_map[element.key]
100
+ node_type = element.context_node.definition.type.name
91
101
  response_class.class_eval do
92
102
  define_method definition.underscore do |**rest_of_options|
93
- @row[index]
103
+ convert_type node_type, @row[index]
94
104
  end
95
105
  end
96
106
  end
97
107
 
98
108
 
99
-
100
109
  end
101
110
  end
@@ -1,5 +1,5 @@
1
1
  module Activecube
2
2
  module Graphql
3
- VERSION = "0.1.1"
3
+ VERSION = "0.1.2"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activecube-graphql
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.1.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Aleksey Studnev
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-02-24 00:00:00.000000000 Z
11
+ date: 2020-03-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activecube
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - "~>"
18
18
  - !ruby/object:Gem::Version
19
- version: 0.1.3
19
+ version: 0.1.4
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - "~>"
25
25
  - !ruby/object:Gem::Version
26
- version: 0.1.3
26
+ version: 0.1.4
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: graphql
29
29
  requirement: !ruby/object:Gem::Requirement