kennel 1.158.0 → 1.159.0

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: 0622cc6a3d8c7a66e692373a5cbd88ceafc6fa6d705524492a06c5e2c67e4204
4
- data.tar.gz: d1c057023a8c6d0f093b752ec8cc64c9a8fa185e49d5251b44eeeb87f2441377
3
+ metadata.gz: afa96484d3351de6a715ca440d8a22d3eb81012866a08987b0ddce36b568ae48
4
+ data.tar.gz: 5f8d189f4447e998711ae07a1ee245c56c0453569a5a43e12ca8a9e9c3184030
5
5
  SHA512:
6
- metadata.gz: fcfb2a52f2cbbe918d77bebfc2fc19334ad892691a538bd14dc043b52bbf71bcebb11793704798069a7779d20cf67cb096c88347c1f14d35e4a16b691ad3f99a
7
- data.tar.gz: d21f845c889de0d9bcfc8e54fefa141e1abfaa3a50bd2556294e468c191d15eaa48cbf054c6f1b1c4f0a7d43b8d5df780f0e3e567b9002826bb6dffa5f1550b7
6
+ metadata.gz: a3886ae264c55d8112de1f16e7d0af92b97d1ecbf470219ff7131cb45df6fa115ef14142cc3c31056e88a135bb2c4091d15fd9a160a624875f2758db23ad70d8
7
+ data.tar.gz: 072d6d09e64c55e1a0c167ec884dfcf17102c05fdba614b5bbc1132e3c582cb5699c6bfdf1faf4d6a5d5d0b7b702adbc94b82753b20530d1d3d435593cea774a
@@ -2,12 +2,9 @@
2
2
 
3
3
  module Kennel
4
4
  class Importer
5
- # title will have the lock symbol we need to remove when re-importing
6
- TITLES = [:name, :title].freeze
7
-
8
5
  # bring important fields to the top
9
6
  SORT_ORDER = [
10
- *TITLES, :id, :kennel_id, :type, :tags, :query, :sli_specification,
7
+ *Kennel::Models::Record::TITLE_FIELDS, :id, :kennel_id, :type, :tags, :query, :sli_specification,
11
8
  *Models::Record.subclasses.flat_map { |k| k::TRACKING_FIELDS },
12
9
  :template_variables
13
10
  ].freeze
@@ -31,9 +28,10 @@ module Kennel
31
28
  model.normalize({}, data) # removes id
32
29
  data[:id] = id
33
30
 
34
- title_field = TITLES.detect { |f| data[f] }
31
+ # title will have the lock symbol we need to remove when re-importing
32
+ title_field = Kennel::Models::Record::TITLE_FIELDS.detect { |f| data[f] }
35
33
  title = data.fetch(title_field)
36
- title.tr!(Kennel::Models::Record::LOCK, "") # avoid double lock icon
34
+ title.tr!(Kennel::Models::Record::LOCK, "")
37
35
 
38
36
  # calculate or reuse kennel_id
39
37
  data[:kennel_id] =
@@ -26,6 +26,7 @@ module Kennel
26
26
  :deleted, :id, :created, :created_at, :creator, :org_id, :modified, :modified_at,
27
27
  :klass, :tracking_id # added by syncer.rb
28
28
  ].freeze
29
+ TITLE_FIELDS = [:name, :title].freeze # possible fields that could have the title
29
30
  ALLOWED_KENNEL_ID_CHARS = "a-zA-Z_\\d.-"
30
31
  ALLOWED_KENNEL_ID_SEGMENT = /[#{ALLOWED_KENNEL_ID_CHARS}]+/
31
32
  ALLOWED_KENNEL_ID_FULL = "#{ALLOWED_KENNEL_ID_SEGMENT}:#{ALLOWED_KENNEL_ID_SEGMENT}".freeze
data/lib/kennel/syncer.rb CHANGED
@@ -89,6 +89,24 @@ module Kennel
89
89
 
90
90
  # see which expected match the actual
91
91
  matching, unmatched_expected, unmatched_actual = MatchedExpected.partition(expected, actual)
92
+ unmatched_actual.select! { |a| a.fetch(:tracking_id) } # ignore items that were never managed by kennel
93
+
94
+ # if there is a new item that has the same name/title as a to be deleted item, we should just update it
95
+ # careful with unmatched_expected being huge since it has all api resources
96
+ unmatched_expected.reject! do |e|
97
+ actual = unmatched_actual.detect do |a|
98
+ a[:klass] == e.class &&
99
+ Kennel::Models::Record::TITLE_FIELDS.any? { |f| (set = a[f]) && set == e.as_json.fetch(f) }
100
+ end
101
+ next false unless actual # keep in unmatched
102
+
103
+ unmatched_actual.delete(actual)
104
+ actual[:tracking_id] = e.tracking_id
105
+ matching << [e, actual]
106
+
107
+ true # remove from unmatched
108
+ end
109
+
92
110
  validate_expected_id_not_missing unmatched_expected
93
111
  fill_details! matching # need details to diff later
94
112
 
@@ -105,7 +123,7 @@ module Kennel
105
123
  end.compact
106
124
 
107
125
  # delete previously managed
108
- deletes = unmatched_actual.map { |a| Types::PlannedDelete.new(a) if a.fetch(:tracking_id) }.compact
126
+ deletes = unmatched_actual.map { |a| Types::PlannedDelete.new(a) }
109
127
 
110
128
  # unmatched expected need to be created
111
129
  unmatched_expected.each(&:add_tracking_id)
@@ -1,4 +1,4 @@
1
1
  # frozen_string_literal: true
2
2
  module Kennel
3
- VERSION = "1.158.0"
3
+ VERSION = "1.159.0"
4
4
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: kennel
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.158.0
4
+ version: 1.159.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Michael Grosser
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-28 00:00:00.000000000 Z
11
+ date: 2025-04-02 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: diff-lcs