activecube 0.1.29 → 0.1.30
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/activecube/definition_methods.rb +2 -1
- data/lib/activecube/query/cube_query.rb +7 -0
- data/lib/activecube/query/limit_by.rb +19 -0
- data/lib/activecube/query/slice.rb +12 -3
- data/lib/activecube/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 663ae546f63257569c7692d59478ffef3c954f2c9a74f53c78ae6ee31bdf093c
|
4
|
+
data.tar.gz: df61b6a95415e4879d62b0eada8abcf732d9d7aeca882c72fa28ca929c567db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e25d8a4f05d9880c4c3acbf6854393556902e0339976701949ab5b56bc3d627f20a9790144c19f00903786fa0abd947c2cb866bdc5d41856483cd8e030a281d1
|
7
|
+
data.tar.gz: 418d88e3f5d6249de2781faa1f27cfc42d219538eac7c2d68611735771cf8d2413ac2a1e626559d7b8f0d0248852358a58ea5400af2a561248cb1a591126e49a
|
data/Gemfile.lock
CHANGED
@@ -31,13 +31,14 @@ module Activecube
|
|
31
31
|
|
32
32
|
include DefinitionMethods
|
33
33
|
|
34
|
-
attr_reader :identity, :fields
|
34
|
+
attr_reader :identity, :identity_expression, :fields
|
35
35
|
|
36
36
|
private
|
37
37
|
|
38
38
|
def identity_column *args
|
39
39
|
raise "Identity already defined as #{identity} for #{self.name}" if @identity
|
40
40
|
@identity = args.first
|
41
|
+
@identity_expression = args.second
|
41
42
|
end
|
42
43
|
|
43
44
|
def field *args
|
@@ -1,6 +1,7 @@
|
|
1
1
|
require 'activecube/query/chain_appender'
|
2
2
|
require 'activecube/query/item'
|
3
3
|
require 'activecube/query/limit'
|
4
|
+
require 'activecube/query/limit_by'
|
4
5
|
require 'activecube/query/measure'
|
5
6
|
require 'activecube/query/ordering'
|
6
7
|
require 'activecube/query/option'
|
@@ -82,6 +83,12 @@ module Activecube::Query
|
|
82
83
|
self
|
83
84
|
end
|
84
85
|
|
86
|
+
def limit_by *args
|
87
|
+
clear_sql
|
88
|
+
options << LimitBy.new(args)
|
89
|
+
self
|
90
|
+
end
|
91
|
+
|
85
92
|
|
86
93
|
def query
|
87
94
|
sql = to_query.to_sql
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module Activecube
|
2
|
+
module Query
|
3
|
+
class LimitBy
|
4
|
+
|
5
|
+
attr_reader :each, :limit, :offset
|
6
|
+
def initialize arguments
|
7
|
+
map = Hash[arguments]
|
8
|
+
@each = map[:each]
|
9
|
+
@limit = map[:limit]
|
10
|
+
@offset = map[:offset] || 0
|
11
|
+
end
|
12
|
+
|
13
|
+
def append_query _model, _cube_query, _table, query
|
14
|
+
query.limit_by each, limit, offset
|
15
|
+
end
|
16
|
+
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
@@ -68,11 +68,20 @@ module Activecube::Query
|
|
68
68
|
query = query.project(expr.as(attr_alias))
|
69
69
|
|
70
70
|
if dimension.class.identity
|
71
|
+
expr = dimension.class.identity_expression
|
71
72
|
group_by_columns.each do |column|
|
72
|
-
|
73
|
-
|
73
|
+
|
74
|
+
node = if column==dimension.class.identity && expr
|
75
|
+
Arel.sql(expr).as(column)
|
76
|
+
else
|
77
|
+
table[column]
|
78
|
+
end
|
79
|
+
|
80
|
+
unless query.projections.include?(node)
|
81
|
+
query = query.project(node)
|
74
82
|
end
|
75
|
-
|
83
|
+
|
84
|
+
query = query.group( expr ? column : table[column])
|
76
85
|
end
|
77
86
|
else
|
78
87
|
query = query.group(attr_alias)
|
data/lib/activecube/version.rb
CHANGED
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.30
|
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-
|
11
|
+
date: 2020-11-30 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -108,6 +108,7 @@ files:
|
|
108
108
|
- lib/activecube/query/cube_query.rb
|
109
109
|
- lib/activecube/query/item.rb
|
110
110
|
- lib/activecube/query/limit.rb
|
111
|
+
- lib/activecube/query/limit_by.rb
|
111
112
|
- lib/activecube/query/measure.rb
|
112
113
|
- lib/activecube/query/measure_nothing.rb
|
113
114
|
- lib/activecube/query/modification.rb
|