brick 1.0.234 → 1.0.235

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: de2c4e94eca5667096154e57b49fc68273d85d5aa4f3830d68781f742204aa4c
4
- data.tar.gz: 181c532f44cea33088556c7a1c54525898209335fde70d4328faeb09cf55bd54
3
+ metadata.gz: dbee410a881406dbcec60714bf2688d0cbc4aef0c89a68888ce9f2401e0005dd
4
+ data.tar.gz: b1a06757052b4130080b6a8762b1d7f8522f551956850bb8c2fe6655260380eb
5
5
  SHA512:
6
- metadata.gz: dafe49d283394fc7d411241662a3910266fb98e82679c3ac6aa575b88f6f640908dced9e62ccf077544c2a9732a43b6bc0691a20f83f44d4caa8d9621884dd63
7
- data.tar.gz: 37db140de791a556266a43bd3ee4040d412e0436ffac0e6bf5fb5a11108f3030226c59710b801237176c935963418ea2cd9f1de2e4a6c3beb76dc3138640500e
6
+ metadata.gz: 2eca4cb00874a367159483ac23a6a03d273d5b5bd54913272f99a7ffefc26e2bbaced2a52b9df624320912e9b70445a432dd4694e5ccc673cb60187633e87d91
7
+ data.tar.gz: 381d498e42a473cf92cd556b843c59eb08618b0c8f2e61808689a4f1b4c2d5a0e0078d171d64b055cedca78d81bf5fbcfa73eff5268ca3d9d56076ec1c505299
@@ -5,7 +5,7 @@ module Brick
5
5
  module VERSION
6
6
  MAJOR = 1
7
7
  MINOR = 0
8
- TINY = 234
8
+ TINY = 235
9
9
 
10
10
  # PRE is nil unless it's a pre-release (beta, RC, etc.)
11
11
  PRE = nil
@@ -70,7 +70,7 @@ module Brick
70
70
  indexes = {} # Track index names to make sure things are unique
71
71
  ar_base = Object.const_defined?(:ApplicationRecord) ? ApplicationRecord : Class.new(ActiveRecord::Base)
72
72
  atrt_idx = 0 # ActionText::RichText unique index number
73
- airtable_assoc_recids = Hash.new { |h, k| h[k] = [] }
73
+ airtable_assoc_recids = Hash.new { |h, k| h[k] = {} }
74
74
  @has_atrts = nil # Any ActionText::RichText present?
75
75
  # Start by making entries for fringe models (those with no foreign keys).
76
76
  # Continue layer by layer, creating entries for models that reference ones already done, until
@@ -168,8 +168,9 @@ module Brick
168
168
  far_side_fk = associative_fks.find { |_k, fk1| fk1[:is_bt] && fk1[:assoc_name] != ::Brick::AirtableApiCaller.sane_name(field.first) }&.last
169
169
  field.last.each do |nm_rec|
170
170
  # Can trade out: hm_fk[:fk] for: near_side_fk[:inverse_table]
171
- airtable_assoc_recids[assoc_table] << "#{hm_fk[:fk]}: #{hm_fk[:fk].singularize}_#{nm_rec[3..-1]}, " \
172
- "#{far_side_fk[:assoc_name]}: #{far_side_fk[:inverse_table].singularize}_#{obj['id'][3..-1]}"
171
+ airtable_assoc_recids[assoc_table][[nm_rec[3..-1], obj['id'][3..-1]].sort.join] =
172
+ "#{hm_fk[:fk]}: #{hm_fk[:fk].singularize}_#{nm_rec[3..-1]}, " \
173
+ "#{far_side_fk[:assoc_name]}: #{far_side_fk[:inverse_table].singularize}_#{obj['id'][3..-1]}"
173
174
  end
174
175
  end
175
176
  end
@@ -266,10 +267,21 @@ end\n"
266
267
  done.concat(fringe)
267
268
  chosen -= done
268
269
  end
269
- airtable_assoc_recids.each do |k, v| # N:M links
270
- v.each do |link|
271
- seeds << "#{k.singularize.camelize}.create(#{link})\n"
270
+ airtable_assocs_done = {}
271
+ airtable_assoc_recids.each do |table_name, assoc_pairs| # N:M links
272
+ # Make note of any other tables which have exactly duplicated data
273
+ dupes = airtable_assocs_done.select do |dupe_table, dupe_pairs|
274
+ dupe_table != table_name && assoc_pairs.length > 0 && assoc_pairs.length == dupe_pairs.length &&
275
+ dupe_pairs.all? { |pair_name, _v3| assoc_pairs.keys.include?(pair_name) }
272
276
  end
277
+ seeds << " if ActiveRecord::Migration.table_exists?('#{table_name}')\n"
278
+ seeds << " # Duplicate data found in: #{dupes.keys.join(', ')}\n" unless dupes.empty?
279
+ seeds << " puts 'Seeding Airtable associations for #{table_name.camelize.singularize}'\n"
280
+ assoc_pairs.each do |_k2, pair_values|
281
+ seeds << "#{table_name.singularize.camelize}.create(#{pair_values})\n"
282
+ end
283
+ seeds << " end\n"
284
+ airtable_assocs_done[table_name] = assoc_pairs
273
285
  end
274
286
 
275
287
  File.open(seed_file_path, "w") { |f| f.write seeds }
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: brick
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.234
4
+ version: 1.0.235
5
5
  platform: ruby
6
6
  authors:
7
7
  - Lorin Thwaits
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-03-19 00:00:00.000000000 Z
11
+ date: 2025-03-20 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord