activecube 0.1.15 → 0.1.23
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 +4 -4
- data/Gemfile.lock +1 -1
- data/lib/activecube.rb +1 -0
- data/lib/activecube/cube_definition.rb +5 -1
- data/lib/activecube/query/cube_query.rb +13 -1
- data/lib/activecube/query/option.rb +17 -0
- data/lib/activecube/query/selector.rb +4 -4
- data/lib/activecube/query_methods.rb +5 -2
- data/lib/activecube/version.rb +1 -1
- data/lib/activecube/view.rb +34 -0
- data/lib/activecube/view_connection.rb +11 -0
- data/lib/activecube/view_definition.rb +16 -0
- metadata +6 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f4761a4080baea000688c32cd35753b72f0fd51d7e6a0818da31c8bd5141f966
|
4
|
+
data.tar.gz: e5116aa48a23176bd91f4e90bbf6d83ac300c09aa3c04a951afbe8eeb3918133
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2638118ea471ff784d1689a86dde10a535dcfd0e4eabeb93a9b6206236f116017ffe5d08de03820adb45d5e4291b42ca853c755efa5cddf37d664a09e3122ea9
|
7
|
+
data.tar.gz: 6339c6bad22e0c0fbebbd2e8987ccac2085374fa31e274c902963b5de5b8f5dd6531b19dc95c79ccf9e1722ee277bb469a1bddc03d41d991d8fe64cafa61c63e
|
data/Gemfile.lock
CHANGED
data/lib/activecube.rb
CHANGED
@@ -18,7 +18,7 @@ module Activecube
|
|
18
18
|
|
19
19
|
end
|
20
20
|
|
21
|
-
attr_reader :dimensions, :metrics, :selectors, :models
|
21
|
+
attr_reader :dimensions, :metrics, :selectors, :models, :options
|
22
22
|
|
23
23
|
def inspect
|
24
24
|
name +
|
@@ -46,6 +46,10 @@ module Activecube
|
|
46
46
|
store_definition_array! 'model', (@models ||= []), [*args].flatten.map{|t| t }
|
47
47
|
end
|
48
48
|
|
49
|
+
def option *args
|
50
|
+
store_definition_array! 'option', (@options ||= []), [*args].flatten.map{|t| t }
|
51
|
+
end
|
52
|
+
|
49
53
|
def dim_column column_name
|
50
54
|
Class.new(Activecube::Dimension) do
|
51
55
|
column column_name
|
@@ -3,6 +3,7 @@ require 'activecube/query/item'
|
|
3
3
|
require 'activecube/query/limit'
|
4
4
|
require 'activecube/query/measure'
|
5
5
|
require 'activecube/query/ordering'
|
6
|
+
require 'activecube/query/option'
|
6
7
|
require 'activecube/query/selector'
|
7
8
|
require 'activecube/query/slice'
|
8
9
|
|
@@ -20,7 +21,18 @@ module Activecube::Query
|
|
20
21
|
@measures = measures
|
21
22
|
@selectors = selectors
|
22
23
|
@options = options
|
23
|
-
|
24
|
+
|
25
|
+
@tables = model_tables || cube.models.map{|m|
|
26
|
+
m < Activecube::View ? m.new : Activecube::Processor::Table.new(m)
|
27
|
+
}
|
28
|
+
|
29
|
+
cube.options && cube.options.each do |option|
|
30
|
+
define_singleton_method option.to_s.underscore do |*args|
|
31
|
+
@options << Option.new(option, *args)
|
32
|
+
self
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
24
36
|
end
|
25
37
|
|
26
38
|
def slice *args
|
@@ -0,0 +1,17 @@
|
|
1
|
+
module Activecube
|
2
|
+
module Query
|
3
|
+
class Option
|
4
|
+
|
5
|
+
attr_reader :argument, :value
|
6
|
+
def initialize argument, value
|
7
|
+
@argument = argument
|
8
|
+
@value = value
|
9
|
+
end
|
10
|
+
|
11
|
+
def append_query _model, _cube_query, _table, query
|
12
|
+
query
|
13
|
+
end
|
14
|
+
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
@@ -20,13 +20,13 @@ module Activecube::Query
|
|
20
20
|
end
|
21
21
|
|
22
22
|
def to_s
|
23
|
-
"Selector
|
23
|
+
"Selector #{operator.operation}(#{@selectors.map(&:to_s).join(',')})"
|
24
24
|
end
|
25
25
|
|
26
26
|
def expression model, arel_table, cube_query
|
27
27
|
expr = nil
|
28
28
|
@selectors.each do |s|
|
29
|
-
expr = expr ? expr.send(
|
29
|
+
expr = expr ? expr.send( operator.operation, s.expression(model, arel_table, cube_query)) : s.expression(model, arel_table, cube_query)
|
30
30
|
end
|
31
31
|
expr
|
32
32
|
end
|
@@ -137,11 +137,11 @@ module Activecube::Query
|
|
137
137
|
end
|
138
138
|
|
139
139
|
def self.or(selectors)
|
140
|
-
CombineSelector.new(selectors, :or)
|
140
|
+
CombineSelector.new(selectors, Operator.new(:or, nil) )
|
141
141
|
end
|
142
142
|
|
143
143
|
def self.and(selectors)
|
144
|
-
CombineSelector.new(selectors, :and)
|
144
|
+
CombineSelector.new(selectors, Operator.new(:and, nil))
|
145
145
|
end
|
146
146
|
|
147
147
|
end
|
@@ -24,9 +24,12 @@ module Activecube
|
|
24
24
|
|
25
25
|
|
26
26
|
def super_model
|
27
|
-
raise Activecube::InputArgumentError, "No tables specified for cube #{name}"
|
27
|
+
raise Activecube::InputArgumentError, "No tables specified for cube #{name}" unless models && models.count>0
|
28
28
|
|
29
|
-
|
29
|
+
|
30
|
+
models.collect{|m|
|
31
|
+
m < View ? m.models : m
|
32
|
+
}.flatten.uniq.collect{ |t|
|
30
33
|
t.ancestors.select{|c| c < ActiveRecord::Base }
|
31
34
|
}.transpose.select{|c|
|
32
35
|
c.uniq.count==1
|
data/lib/activecube/version.rb
CHANGED
@@ -0,0 +1,34 @@
|
|
1
|
+
require 'activecube/view_definition'
|
2
|
+
require 'activecube/view_connection'
|
3
|
+
|
4
|
+
module Activecube
|
5
|
+
class View
|
6
|
+
extend ViewDefinition
|
7
|
+
extend ViewConnection
|
8
|
+
|
9
|
+
def model
|
10
|
+
self.class
|
11
|
+
end
|
12
|
+
|
13
|
+
def name
|
14
|
+
model.name
|
15
|
+
end
|
16
|
+
|
17
|
+
def matches? query, _measures = query.measures
|
18
|
+
true
|
19
|
+
end
|
20
|
+
|
21
|
+
def measures? measure
|
22
|
+
true
|
23
|
+
end
|
24
|
+
|
25
|
+
def query _cube_query
|
26
|
+
raise "query method have to be implemented in #{name}"
|
27
|
+
end
|
28
|
+
|
29
|
+
def join _cube_query, _left_query, _right_query
|
30
|
+
raise "join method have to be implemented in #{name}"
|
31
|
+
end
|
32
|
+
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
require 'active_support/concern'
|
2
|
+
|
3
|
+
module Activecube::ViewDefinition
|
4
|
+
|
5
|
+
attr_reader :activecube_indexes, :models
|
6
|
+
|
7
|
+
def index index_name, *args
|
8
|
+
(@activecube_indexes ||= []) << Activecube::Processor::Index.new(index_name,*args)
|
9
|
+
end
|
10
|
+
|
11
|
+
def table x
|
12
|
+
(@models ||= []) << x
|
13
|
+
end
|
14
|
+
|
15
|
+
|
16
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: activecube
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.23
|
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-
|
11
|
+
date: 2020-05-28 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -111,12 +111,16 @@ files:
|
|
111
111
|
- lib/activecube/query/measure.rb
|
112
112
|
- lib/activecube/query/measure_nothing.rb
|
113
113
|
- lib/activecube/query/modification.rb
|
114
|
+
- lib/activecube/query/option.rb
|
114
115
|
- lib/activecube/query/ordering.rb
|
115
116
|
- lib/activecube/query/selector.rb
|
116
117
|
- lib/activecube/query/slice.rb
|
117
118
|
- lib/activecube/query_methods.rb
|
118
119
|
- lib/activecube/selector.rb
|
119
120
|
- lib/activecube/version.rb
|
121
|
+
- lib/activecube/view.rb
|
122
|
+
- lib/activecube/view_connection.rb
|
123
|
+
- lib/activecube/view_definition.rb
|
120
124
|
homepage: https://github.com/bitquery/activecube
|
121
125
|
licenses:
|
122
126
|
- MIT
|