bulk_ops 0.1.12 → 0.1.13

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: d5769c63fe85e0a97a16da3f147f2788af3ce5114ac84fd9ea1e3078f187ce11
4
- data.tar.gz: 6164cafacea7e4f88cb39464ad2cf19cd38268f63cf4fdccda6f0bee35cc3515
3
+ metadata.gz: b118e0e6b4039a3fff3174e553faaa05c447c09b08c3ea5ad013ba8922b09084
4
+ data.tar.gz: d27b01baf50a45da61d1131f8a84a61bd0b2db6bbfd23742a49b508e55cdecd3
5
5
  SHA512:
6
- metadata.gz: e93c25e5bf47b3d9230b78b42695871bb4c7905270c9f9eeda92e459f030e4a74cc32e5a362e2224a1817ee0dd3f639b36aa573032d90cea00aaf0c3b4c9717a
7
- data.tar.gz: 307ad0126fd62baa1a21b7f0ca5073c0847a27435a0665955aa3df68df24a28b85b96396ba01ef966e82d9b218e6b728ef46cd03ec8bcfbb369b18c56d24d32e
6
+ metadata.gz: 75b9f53d064c5cdef7044c7b727fe36d2ccd1fcfb50bf522b5c45375fb7c6f548a9fbe1bc88ef4cfe757dac1f44af4d4b2d503246a98b65891883c1e08d1dc75
7
+ data.tar.gz: 32faf9307eb850f7a306d7e3c9c088b53faf63fd9a25578c04b6facdcb6647eca0fb38c26253c078772d2e49715e559a7b3bc655fa349791dbf33b6070edded1
@@ -150,7 +150,7 @@ module BulkOps
150
150
 
151
151
  work_proxies.each do |proxy|
152
152
  wrk = Work.find(proxy.work_id)
153
- wrk.save if wrk.members.any?{|mem| mem.class.to_s !== "FileSet"}
153
+ wrk.save if wrk.members.any?{|mem| mem.class.to_s != "FileSet"}
154
154
  sd = SolrDocument.find(wrk.id)
155
155
  wrk.save if sd['hasRelatedImage_ssim'].present? && sd['relatedImageId_ss'].blank?
156
156
  end
@@ -58,7 +58,7 @@ class BulkOps::Relationship < ActiveRecord::Base
58
58
  implement_relationship! relationship_type, subject, object
59
59
  end
60
60
 
61
- def insert_among_siblings(object,new_member)
61
+ def insert_among_children(object,new_member)
62
62
  return nil unless ["parent"].include?(relationship_type.downcase)
63
63
  prev_sib_id = previous_sibling
64
64
  # This is the id of the WorkProxy associate with the most recent sibling work
@@ -68,7 +68,8 @@ class BulkOps::Relationship < ActiveRecord::Base
68
68
  prev_sib_proxy = BulkOps::WorkProxy.find(previous_sibling)
69
69
  # Check if the previous sibling is fully ingested
70
70
  # and get its index among its siblings (if it has been successfully attached to the parent)
71
- prev_sib_index = object.ordered_member_ids.index(prev_sib_proxy.work_id) if prev_sib_proxy.work_id.present? # Insert the new member among its siblings if we found the right place
71
+ prev_sib_index = object.ordered_member_ids.index(prev_sib_proxy.work_id) if prev_sib_proxy.work_id.present?
72
+ # Insert the new member among its siblings if we found the right place
72
73
  return object.ordered_members.to_a.insert(prev_sib_index+1, new_member) if prev_sib_index.present?
73
74
  # Otherwise, pull up the sibling's relationship field to check if it sibling has a sibling before it
74
75
  sib_relationship = prev_sib_proxy.relationships.find_by(relationship_type: relationship_type, object_identifier: object_identifier)
@@ -77,14 +78,15 @@ class BulkOps::Relationship < ActiveRecord::Base
77
78
  break unless sib_relationship.present?
78
79
  prev_sib_id = sib_relationship.previous_sibling
79
80
  end
80
- return [new_member]+ordered_members.to_a
81
+ #If we never found an existing previous sibling already attached, put this one at the front
82
+ return [new_member]+object.ordered_members.to_a
81
83
  end
82
84
 
83
85
  def implement_relationship!(type,subject,object)
84
86
  case type.downcase
85
87
  when "parent"
86
88
  unless object.member_ids.include? subject.id
87
- object.ordered_members = insert_among_siblings(object, new_member)
89
+ object.ordered_members = insert_among_children(object, subject)
88
90
  object.save
89
91
  end
90
92
  when "child"
@@ -1,3 +1,3 @@
1
1
  module BulkOps
2
- VERSION = "0.1.12"
2
+ VERSION = "0.1.13"
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: bulk_ops
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.12
4
+ version: 0.1.13
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ned Henry, UCSC Library Digital Initiatives