fix: correct subregion initialization by name
- Change the method of finding or initializing subregions to use the name attribute instead of the id. - This improves accuracy when synchronizing subregion data, as it ensures that subregions are correctly matched by name. - Eliminates potential issues with duplicate IDs if they happen to be reused across different data sources.
This commit is contained in:
parent
bafb889144
commit
e774b3e736
@ -42,8 +42,7 @@ namespace :geo do
|
|||||||
count = 1
|
count = 1
|
||||||
|
|
||||||
subregions.each do |data|
|
subregions.each do |data|
|
||||||
subregion = Subregion.find_or_initialize_by(id: data["id"]) do |s|
|
subregion = Subregion.find_or_initialize_by(name: data["name"]) do |s|
|
||||||
s.name = data["name"]
|
|
||||||
s.region_id = data["region_id"]
|
s.region_id = data["region_id"]
|
||||||
end
|
end
|
||||||
puts "Sync Subregions[#{count}/#{sum}]: [#{subregion.name}]"
|
puts "Sync Subregions[#{count}/#{sum}]: [#{subregion.name}]"
|
||||||
|
Loading…
Reference in New Issue
Block a user