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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 21b32d45c2412d7be46e4f044b3287262b5014ad617ac9929fc0f740c7c64520
4
- data.tar.gz: f5c97c62544274087c0ca1cfedf403384f3dc04bb05ba327cc2c51a6a5bc9ff0
3
+ metadata.gz: 663ae546f63257569c7692d59478ffef3c954f2c9a74f53c78ae6ee31bdf093c
4
+ data.tar.gz: df61b6a95415e4879d62b0eada8abcf732d9d7aeca882c72fa28ca929c567db1
5
5
  SHA512:
6
- metadata.gz: ee2dd6dc3bcb0b4f1b2acc83aceb94d677564d2c70c51646018b0b91c2e168f41459cc0e7541e5b4182aebb8bc4e288d88ae2fc017836ca2d1475afb0c28f019
7
- data.tar.gz: '0709d3aa9adef226869f016a46d58a11cbfee94315fac2f22c7740ca3bf215c8ab691191a9b6ce50e69ed3ff072de84993bc313cf86f9095b41a71cf5be88072'
6
+ metadata.gz: e25d8a4f05d9880c4c3acbf6854393556902e0339976701949ab5b56bc3d627f20a9790144c19f00903786fa0abd947c2cb866bdc5d41856483cd8e030a281d1
7
+ data.tar.gz: 418d88e3f5d6249de2781faa1f27cfc42d219538eac7c2d68611735771cf8d2413ac2a1e626559d7b8f0d0248852358a58ea5400af2a561248cb1a591126e49a
@@ -9,7 +9,7 @@ GIT
9
9
  PATH
10
10
  remote: .
11
11
  specs:
12
- activecube (0.1.28)
12
+ activecube (0.1.29)
13
13
  activerecord (>= 5.2)
14
14
 
15
15
  GEM
@@ -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
- if !query.projections.detect{|p| p.kind_of?(::Arel::Attributes::Attribute) && p.name==column}
73
- query = query.project(table[column])
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
- query = query.group(table[column])
83
+
84
+ query = query.group( expr ? column : table[column])
76
85
  end
77
86
  else
78
87
  query = query.group(attr_alias)
@@ -1,3 +1,3 @@
1
1
  module Activecube
2
- VERSION = "0.1.29"
2
+ VERSION = "0.1.30"
3
3
  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.29
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-02 00:00:00.000000000 Z
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