klastera 1.4.2 → 1.4.3
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 +17 -6
- 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: e524bc600751df634962778af44d6b9bd782cabdf7a125a145d2a7efbfbe6950
|
4
|
+
data.tar.gz: ab457168729e69d5f1ca94f40ea667b78e3610993eaa686998e8aa792f865db1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f30c250c13e081a7aebeb66fce89386638d445a92f5dd995c4855483a45efd7bf7927265980fff8ffcef7ca3e9d3f5fc53c618b05babc92464a6986a8878df84
|
7
|
+
data.tar.gz: 97007ff678bbc223506ac5fc53814c9b7363c3e45ba4f39455f73d8abdd1012bab6fd7b126b3237cc42b91fbbb6a969061c72ece12549aa1d84ae0810522a43a
|
data/lib/klastera.rb
CHANGED
@@ -79,9 +79,8 @@ module Klastera
|
|
79
79
|
# cluster_filter_id is present when the optional_suborganization mode is on. BUT!
|
80
80
|
# Be aware that if the cluster_filter is not present, the value of force_cluster_clause
|
81
81
|
# will be overridden by the returned value of cannot_skip_cluster_clause? method.
|
82
|
-
|
83
|
-
|
84
|
-
scope_klass = scope_class(scope_klass)
|
82
|
+
def should_clusterize_scope?(user, organization, cluster_filter=nil, force_cluster_clause=false)
|
83
|
+
should = false # I don't know if this is a good idea
|
85
84
|
if organization.is_in_cluster_mode? && ( cluster_filter.present? || force_cluster_clause = user.cannot_skip_cluster_clause? ) # yes, this is an assignation
|
86
85
|
cluster_ids = []
|
87
86
|
# Set another variable as array to get the cluster id(s)
|
@@ -92,15 +91,27 @@ module Klastera
|
|
92
91
|
end
|
93
92
|
# We will avoid the query unless cluster_ids is having values OR force_cluster_clause is set (see method description)
|
94
93
|
if cluster_ids.present? || force_cluster_clause
|
95
|
-
scope_klass = scope_klass.eager_load(:organization,cluster_entities: :cluster)
|
96
94
|
# We add the unclustered if the value of cluster_filter have the special without_cluster string or as method description says
|
97
95
|
if cluster_ids.delete(UNCLUSTERED_ENTITY) || ( force_cluster_clause && organization.optional_suborganization_mode? )
|
98
96
|
cluster_ids << nil
|
99
97
|
end
|
100
|
-
|
98
|
+
should = true
|
99
|
+
end
|
100
|
+
end
|
101
|
+
yield(should,cluster_ids)
|
102
|
+
end
|
103
|
+
|
104
|
+
#
|
105
|
+
# The cleanest and fast way to clusterize a entity!
|
106
|
+
#
|
107
|
+
def cluster_scope!(scope_klass, user, organization, cluster_filter=nil, force_cluster_clause=false)
|
108
|
+
scope = scope_class(scope_klass)
|
109
|
+
should_clusterize_scope?(user,organization,cluster_filter,force_cluster_clause) do |should,cluster_ids|
|
110
|
+
if should
|
111
|
+
scope = scope.eager_load(:organization,cluster_entities: :cluster).where( cluster_entities: { cluster_id: cluster_ids } )
|
101
112
|
end
|
102
113
|
end
|
103
|
-
|
114
|
+
scope.where(organization_id: organization)
|
104
115
|
end
|
105
116
|
|
106
117
|
#
|
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.3
|
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-08 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|