klastera 1.4.1 → 1.4.2

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: f45dc24f8870c8dc07dc2e7702f6021b66b5c71b97529ca4aece12ce47399348
4
- data.tar.gz: 1c8673aaef5fb0d562376e80cdf787e302601672e4a4285066f3be4da04fb925
3
+ metadata.gz: dc8d3414d044460f33127e9eef4f0cb7cc6e6b83333697a944e5248cfe4970fd
4
+ data.tar.gz: 063dbb2a15f6b98b0219ac5af5059b40fa1da440c2e298a6140be4637ad1a504
5
5
  SHA512:
6
- metadata.gz: c59493dadf8ac3a4b52a235f3a4f96c52cef9668ec215bf9f857bad90c72241ad8564fe11c86f3a212587fba37440c87230487ce10da9bdd09519be907a433ca
7
- data.tar.gz: 838347a85ffdfb1144dad6cf83094ff11fa9a8d78398e70f382a65e51df31d80bc557b3022175e7d13a8ddcbd88567f5c8af1b8a7ca6056194f475ed5d57b12d
6
+ metadata.gz: af3e0d45ee32b14aa1f5b5bb27b246af015bfd6191b93846e52ca5e7789d245c7f068dc741afaa872a76244059dd31e71d543a8c1c8696c0346d183ac1bbb90b
7
+ data.tar.gz: 715adddc9f158ceb9c5eaa60e1318c986355d3f8a9e0c875b72903c053cc21fcf207cae038aefac9a51c4e65ffcf4a76ee13047e4a7dd70f908bcdbb0f202428
@@ -8,5 +8,11 @@ module Klastera::Concerns::ClusterEntity
8
8
  end
9
9
 
10
10
  module ClassMethods
11
+ def left_join_sources_of(scope_klass)
12
+ scope_klass_arel_table = scope_klass.arel_table
13
+ scope_klass_arel_table.join(arel_table, Arel::Nodes::OuterJoin).on(
14
+ scope_klass_arel_table[:id].eq(arel_table[:entity_id]), arel_table[:entity_type].eq(scope_klass.name)
15
+ ).join_sources
16
+ end
11
17
  end
12
18
  end
@@ -110,7 +110,7 @@ module Klastera
110
110
  unclusterized_scope = scope_class(scope_klass)
111
111
 
112
112
  if organization.is_in_cluster_mode? && ( force_cluster_clause || user.cannot_skip_cluster_clause? )
113
- unclusterized_scope = unclusterized_scope.joins(relation => :cluster_entities)
113
+ unclusterized_scope = unclusterized_scope.joins(relation).joins(Klastera::ClusterEntity.left_join_sources_of(cluster_entity_klass))
114
114
  end
115
115
 
116
116
  if scope_klass.respond_to?(:organization)
@@ -158,19 +158,13 @@ module Klastera
158
158
  # instead of the default INNER JOIN provide by ActiveRecord's joins method
159
159
  #
160
160
  def cluster_scope_left_join!(scope_klass,organization)
161
- scope_klass_arel_table = scope_klass.arel_table
162
- cluster_entities_arel_table = Klastera::ClusterEntity.arel_table
163
-
164
- scope_klass_cluster_entities = scope_klass_arel_table.join(cluster_entities_arel_table, Arel::Nodes::OuterJoin).on(
165
- scope_klass_arel_table[:id].eq(cluster_entities_arel_table[:entity_id]), cluster_entities_arel_table[:entity_type].eq(scope_klass.name)
166
- ).join_sources
167
-
168
- cluster_arel_table = ::Cluster.arel_table
169
- cluster_entities_cluster = cluster_entities_arel_table.join(cluster_arel_table, Arel::Nodes::OuterJoin).on(
161
+ cluster_entities_arel_table = Klastera::ClusterEntity.arel_table
162
+ cluster_arel_table = ::Cluster.arel_table
163
+ cluster_entities_cluster = cluster_entities_arel_table.join(cluster_arel_table, Arel::Nodes::OuterJoin).on(
170
164
  cluster_entities_arel_table[:cluster_id].eq(cluster_arel_table[:id]),
171
165
  ).join_sources
172
166
 
173
- scope_class(scope_klass).where(organization_id: organization).joins(scope_klass_cluster_entities).joins(cluster_entities_cluster)
167
+ scope_class(scope_klass).where(organization_id: organization).joins(Klastera::ClusterEntity.left_join_sources_of(scope_klass)).joins(cluster_entities_cluster)
174
168
  end
175
169
  end
176
170
 
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.4.1"
2
+ VERSION = "1.4.2"
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: klastera
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.4.1
4
+ version: 1.4.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Gino Barahona
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-08-05 00:00:00.000000000 Z
11
+ date: 2020-08-07 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails