klastera 1.2.1 → 1.2.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3d1ff69c5abf0d989e26c1bfa2be9da2f8c9f5e8100bd4670f1c70d05c91cb13
4
- data.tar.gz: 3bda3826a8d07270008bd4789ecc0eee72706984d9e3065f64bcc7475b844296
3
+ metadata.gz: 5ca95ff5ffe21289a12131f7090036072103e196af1d81f9110c7896d705f837
4
+ data.tar.gz: c026cb690ec0fdbad89237a64e837b74e5112c50b4339dc78e3bdce03dfd84d5
5
5
  SHA512:
6
- metadata.gz: 39e4ec148db926bd2881d1e88e45b4c6071eccbd9aee45964e5c8d547d83f7513e6b1fc9882dfd6c1b06fe2bd146f0153aa935f4869809e09c554736ca8288e3
7
- data.tar.gz: '09cbc4eb782c613ddfa68c4704dc6511ba77c49137539b2fc7d52c084e25a5ecfc28e52b38231081ddbea920468eac23aadca10449009196bd25a7d7c36e46d0'
6
+ metadata.gz: 1f71455ad531a02b1f46672644f8d77aa98a4c842121de8fa1539e26920690d103e997a22470ea5dfa0efdbce6a970a89a824324343b87d90546aa4ad3653e5b
7
+ data.tar.gz: 1d5962c2c598cc389c67306fcd8bbf10ca7577c07bc89795daf98d774537bac01ddcdbd366c2478a4cfc0ea3b3b9082dd1c20edcf0e58e481d7461b92c71c372
data/Rakefile CHANGED
@@ -14,7 +14,7 @@ RDoc::Task.new(:rdoc) do |rdoc|
14
14
  rdoc.rdoc_files.include('lib/**/*.rb')
15
15
  end
16
16
 
17
- #APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
17
+ APP_RAKEFILE = File.expand_path("../test/dummy/Rakefile", __FILE__)
18
18
  load 'rails/tasks/engine.rake'
19
19
 
20
20
 
@@ -20,8 +20,8 @@ module Klastera::Concerns::Clusterizable
20
20
  end
21
21
  end
22
22
 
23
- def clusters_string_separated_by(separator)
24
- self.cluster_entities.map{|ce|ce.cluster.name}.join(separator)
23
+ def clusters_string_separated_by(separator,attribute=:name)
24
+ self.cluster_entities.map{|ce|ce.cluster.send(attribute)}.join(separator)
25
25
  end
26
26
 
27
27
  def has_one_cluster_entity
@@ -7,6 +7,28 @@ module Klastera
7
7
 
8
8
  class << self
9
9
 
10
+ def set_cluster_entities_attributes!(entity,array_cluster_ids)
11
+ cluster_entities_attributes = {}
12
+ entity_cluster_entities = entity.try(:cluster_entities) || []
13
+ entity_clusters = entity_cluster_entities.map(&:cluster_id).sort
14
+ array_cluster_ids = array_cluster_ids.map(&:id).sort
15
+ if array_cluster_ids != entity_clusters
16
+ now = DateTime.now
17
+ entity_cluster_entities.each_with_index do |ec,index|
18
+ remove_cluster = true
19
+ if array_cluster_ids.include?(ec.cluster_id)
20
+ remove_cluster = false
21
+ array_cluster_ids.delete(ec.cluster_id)
22
+ end
23
+ cluster_entities_attributes[index] = { id: ec.id, cluster_id: ec.cluster_id, _destroy: remove_cluster }
24
+ end
25
+ array_cluster_ids.each_with_index do |cluster_id,index|
26
+ cluster_entities_attributes[now.to_i+index] = { cluster_id: cluster_id, _destroy: false }
27
+ end
28
+ end
29
+ cluster_entities_attributes
30
+ end
31
+
10
32
  #
11
33
  # I like to wrap methods
12
34
  #
@@ -30,7 +52,7 @@ module Klastera
30
52
  # A force cluster organization won't return an entity out of a cluster, but
31
53
  # we don't know if the clusterized entities are fully definition-compliant.
32
54
  cluster_array << nil if cluster_organization.optional_suborganization_mode?
33
- active_record_collection = active_record_collection.where("cluster_entities.cluster_id": cluster_array)
55
+ active_record_collection = active_record_collection.joins(:cluster_entities).where("cluster_entities.cluster_id": cluster_array)
34
56
  end
35
57
  # you may use a block only with clusterizable data
36
58
  yield(active_record_collection) if block_given?
@@ -1,3 +1,3 @@
1
1
  module Klastera
2
- VERSION = "1.2.1"
3
- end
2
+ VERSION = "1.2.2"
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.2.1
4
+ version: 1.2.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-06-01 00:00:00.000000000 Z
11
+ date: 2020-06-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails
@@ -128,7 +128,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
128
128
  - !ruby/object:Gem::Version
129
129
  version: '0'
130
130
  requirements: []
131
- rubygems_version: 3.0.8
131
+ rubygems_version: 3.1.2
132
132
  signing_key:
133
133
  specification_version: 4
134
134
  summary: Clusterization Engine