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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 8d11790c4adc1c5453272730dce9ca59a760bf5a6efcb57d6eefb974cd304aa3
4
- data.tar.gz: a42a54a74634773884f315eda227c42bf34999bf3b9fbeb82c826ce87dd872e2
3
+ metadata.gz: f45dc24f8870c8dc07dc2e7702f6021b66b5c71b97529ca4aece12ce47399348
4
+ data.tar.gz: 1c8673aaef5fb0d562376e80cdf787e302601672e4a4285066f3be4da04fb925
5
5
  SHA512:
6
- metadata.gz: 7c037938caa55966f240959944bec48e155525fedd23f15fa32e8711eb90121247498abe16b57882a9ac2db7e673761f711e377befe921cfe1f0d4018ededc85
7
- data.tar.gz: 3f6bab84a0d94a87362cd08ef68f546ddaba9aba1e6c02ce5108f625f91a166058cb9a103a938beb00643a186780ea7006ce6da25b218f3de4ceddbe229dd318
6
+ metadata.gz: c59493dadf8ac3a4b52a235f3a4f96c52cef9668ec215bf9f857bad90c72241ad8564fe11c86f3a212587fba37440c87230487ce10da9bdd09519be907a433ca
7
+ data.tar.gz: 838347a85ffdfb1144dad6cf83094ff11fa9a8d78398e70f382a65e51df31d80bc557b3022175e7d13a8ddcbd88567f5c8af1b8a7ca6056194f475ed5d57b12d
@@ -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)
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.4.0.3"
2
+ VERSION = "1.4.1"
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.0.3
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-03 00:00:00.000000000 Z
11
+ date: 2020-08-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails