klastera 1.3.1 → 1.3.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/lib/klastera.rb +10 -20
- 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: 4fe09e51ca6d275a070d368cd49d916ff2ad2b02f2c06e2afcec708bda66ef88
|
4
|
+
data.tar.gz: 03d542c381f4eaefa9079d8ca47c33c787658faa0cce87127225f52a069bbd46
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 88d80a8309499a0b61d96a44d3a297fcb87fe9352d46021a7e415a66bb1e2e4776400888396478deacb9108c861bfe69755477e23f9d43ed4273b2ce98206bf5
|
7
|
+
data.tar.gz: 836a8472f3a71fda307b77c4c7c69e038bb9c01f2d364b6fb98817cc096960dca2a4ee7d8eb8735b83fbb1a67bd31e4f168f45871fa79362d6e600ac10aed307
|
data/lib/klastera.rb
CHANGED
@@ -114,40 +114,30 @@ module Klastera
|
|
114
114
|
end
|
115
115
|
|
116
116
|
#
|
117
|
-
#
|
117
|
+
# Optimized version of cluster_scope!
|
118
118
|
#
|
119
|
-
def
|
119
|
+
def same_cluster_scope!(scope,user,organization,cluster_id=nil)
|
120
120
|
scope_klass = scope_class(scope)
|
121
121
|
if organization.is_in_cluster_mode?
|
122
|
-
scope_klass = scope_klass.
|
122
|
+
scope_klass = scope_klass.eager_load(:organization,cluster_entities: :cluster)
|
123
123
|
|
124
124
|
if cluster_id.present?
|
125
125
|
cluster_ids = cluster_id.is_a?(Array) ? cluster_id : [cluster_id]
|
126
126
|
else
|
127
127
|
clusters = cluster_of!(user,organization)
|
128
|
-
cluster_ids = clusters.map(&:id).compact
|
128
|
+
cluster_ids = clusters.map(&:id).compact.sort
|
129
129
|
end
|
130
130
|
|
131
131
|
scope_klass = scope_klass.select("DISTINCT ON (#{scope.table_name}.id) #{scope.table_name}.id, #{scope.table_name}.*, clusters.*")
|
132
132
|
|
133
|
-
if organization.required_suborganization_mode?
|
134
|
-
scope_klass = scope_klass.
|
133
|
+
if organization.required_suborganization_mode?# || cluster_id # If cluster_id is passed NULL clusters are expected, rigth?
|
134
|
+
scope_klass = scope_klass.where( cluster_entities: { cluster_id: cluster_ids } )
|
135
135
|
else
|
136
136
|
or_these_cluster_ids = cluster_ids.present? ? " OR cluster_entities.cluster_id IN (#{cluster_ids.join(",")})" : ""
|
137
|
-
scope_klass = scope_klass.
|
138
|
-
LEFT OUTER JOIN cluster_entities
|
139
|
-
ON entity_id = #{scope.table_name}.id
|
140
|
-
AND entity_type = '#{scope}'
|
141
|
-
").joins("
|
142
|
-
LEFT OUTER JOIN clusters
|
143
|
-
ON clusters.id = cluster_entities.cluster_id
|
144
|
-
").where("cluster_entities.id IS NULL#{or_these_cluster_ids}")
|
145
|
-
end
|
146
|
-
# Provisional fix to avoid unresolved SQL clashes with the main application due to DISTINCT ON clause
|
147
|
-
unless same_scope
|
148
|
-
scope_klass = scope_class(scope).eager_load(:cluster_entities).where(id: scope_klass.map(&:id))
|
137
|
+
scope_klass = scope_klass.where("cluster_entities.id IS NULL#{or_these_cluster_ids}")
|
149
138
|
end
|
150
139
|
end
|
140
|
+
|
151
141
|
scope_klass.where(organization_id: organization)
|
152
142
|
end
|
153
143
|
|
@@ -245,8 +235,8 @@ module Klastera
|
|
245
235
|
Klastera.cluster_scope!(scope, cluster_user, cluster_organization, cluster_id)
|
246
236
|
end
|
247
237
|
|
248
|
-
def
|
249
|
-
Klastera.
|
238
|
+
def same_cluster_scope(scope,cluster_id=nil)
|
239
|
+
Klastera.same_cluster_scope!(scope, cluster_user, cluster_organization, cluster_id)
|
250
240
|
end
|
251
241
|
|
252
242
|
def cluster_of_my_own
|
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.3.
|
4
|
+
version: 1.3.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-
|
11
|
+
date: 2020-07-02 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|