klastera 1.4.1 → 1.4.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 +4 -4
- data/app/models/klastera/concerns/cluster_entity.rb +6 -0
- data/lib/klastera.rb +5 -11
- data/lib/klastera/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: dc8d3414d044460f33127e9eef4f0cb7cc6e6b83333697a944e5248cfe4970fd
|
4
|
+
data.tar.gz: 063dbb2a15f6b98b0219ac5af5059b40fa1da440c2e298a6140be4637ad1a504
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
data/lib/klastera.rb
CHANGED
@@ -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
|
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
|
-
|
162
|
-
|
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(
|
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
|
|
data/lib/klastera/version.rb
CHANGED
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.
|
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-
|
11
|
+
date: 2020-08-07 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|