klastera 1.4.0.3 → 1.4.1
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/lib/klastera.rb +25 -1
- 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: f45dc24f8870c8dc07dc2e7702f6021b66b5c71b97529ca4aece12ce47399348
|
4
|
+
data.tar.gz: 1c8673aaef5fb0d562376e80cdf787e302601672e4a4285066f3be4da04fb925
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c59493dadf8ac3a4b52a235f3a4f96c52cef9668ec215bf9f857bad90c72241ad8564fe11c86f3a212587fba37440c87230487ce10da9bdd09519be907a433ca
|
7
|
+
data.tar.gz: 838347a85ffdfb1144dad6cf83094ff11fa9a8d78398e70f382a65e51df31d80bc557b3022175e7d13a8ddcbd88567f5c8af1b8a7ca6056194f475ed5d57b12d
|
data/lib/klastera.rb
CHANGED
@@ -7,7 +7,7 @@ module Klastera
|
|
7
7
|
|
8
8
|
UNCLUSTERED_POSITION = 9999
|
9
9
|
UNCLUSTERED_ENTITY = 'without_cluster'.freeze
|
10
|
-
KLSTR_HELPERS = %i[ cluster_user cluster_organization cluster_list cluster_scope cluster_scope_through_of user_clusters_string_list ].freeze
|
10
|
+
KLSTR_HELPERS = %i[ cluster_user cluster_organization cluster_list cluster_scope cluster_scope_through_of user_clusters_string_list cluster_scope_left_join ].freeze
|
11
11
|
|
12
12
|
class << self
|
13
13
|
|
@@ -152,6 +152,26 @@ module Klastera
|
|
152
152
|
|
153
153
|
[ kluster_scope, grouped_cluster_scope ]
|
154
154
|
end
|
155
|
+
|
156
|
+
#
|
157
|
+
# A helper that returns a CLUSTER SCOPE to build queries that need explicit LEFT OUTER JOIN clause,
|
158
|
+
# instead of the default INNER JOIN provide by ActiveRecord's joins method
|
159
|
+
#
|
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(
|
170
|
+
cluster_entities_arel_table[:cluster_id].eq(cluster_arel_table[:id]),
|
171
|
+
).join_sources
|
172
|
+
|
173
|
+
scope_class(scope_klass).where(organization_id: organization).joins(scope_klass_cluster_entities).joins(cluster_entities_cluster)
|
174
|
+
end
|
155
175
|
end
|
156
176
|
|
157
177
|
##################################################################################################################################################
|
@@ -193,6 +213,10 @@ module Klastera
|
|
193
213
|
Klastera.user_clusters_string_list!(cluster_user, cluster_organization, object_entity.try(:cluster_entities), separator, attribute)
|
194
214
|
end
|
195
215
|
|
216
|
+
def cluster_scope_left_join(scope_klass)
|
217
|
+
Klastera.cluster_scope_left_join!(scope_klas,cluster_organization)
|
218
|
+
end
|
219
|
+
|
196
220
|
included do
|
197
221
|
Klastera::KLSTR_HELPERS.each do |action|
|
198
222
|
if respond_to?(:helper_method)
|
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.1
|
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-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|