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 +4 -4
- data/lib/brick/version_number.rb +1 -1
- data/lib/generators/brick/seeds_builder.rb +18 -6
- 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: dbee410a881406dbcec60714bf2688d0cbc4aef0c89a68888ce9f2401e0005dd
|
4
|
+
data.tar.gz: b1a06757052b4130080b6a8762b1d7f8522f551956850bb8c2fe6655260380eb
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2eca4cb00874a367159483ac23a6a03d273d5b5bd54913272f99a7ffefc26e2bbaced2a52b9df624320912e9b70445a432dd4694e5ccc673cb60187633e87d91
|
7
|
+
data.tar.gz: 381d498e42a473cf92cd556b843c59eb08618b0c8f2e61808689a4f1b4c2d5a0e0078d171d64b055cedca78d81bf5fbcfa73eff5268ca3d9d56076ec1c505299
|
data/lib/brick/version_number.rb
CHANGED
@@ -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]
|
172
|
-
|
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
|
-
|
270
|
-
|
271
|
-
|
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.
|
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-
|
11
|
+
date: 2025-03-20 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|