mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-10-20 06:01:32 -04:00
Remove superfluous* error-checks from load_altnames
* /me crosses fingers...
This commit is contained in:
1 parent
36be5e9533
commit
06a4fcab71
2 files changed
+3
-12
No files matched your search
@@ -1,4 +1,3 @@
|
||||
Id,Name,Alternate names (comma separated)
|
||||
1,achiote,"aploppas, uruku"
|
||||
2,ackee,"achee, ackee apple, akee"
|
||||
267,acorn squash,"pepper squash, Des Moines squash"
|
||||
@@ -380,4 +379,4 @@ Id,Name,Alternate names (comma separated)
|
||||
,Palmers Amaranth,"Palmer amaranth, Palmer's pigweed, carelessweed"
|
||||
,Red-Root Amaranth,"redroot pigweed, red-rooted pigweed, common amaranth, pigweed amaranth, common tumbleweed"
|
||||
,Spiny Amaranth,"prickly amaranth, thorny amaranth"
|
||||
,Tandaljo,"Tandalja bhaji, callaloo, Joseph's coat "
|
||||
,Tandaljo,"Tandalja bhaji, callaloo, Joseph's coat "
|
||||
|
@@ -279,22 +279,14 @@ namespace :growstuff do
|
||||
cropbot = Member.find_by_login_name("cropbot")
|
||||
CSV.foreach(file) do |row|
|
||||
crop_id, crop_name, alternate_names = row
|
||||
if crop_name.blank? or alternate_names.blank? then
|
||||
if alternate_names.blank? then
|
||||
next
|
||||
end
|
||||
crop = Crop.find_by_name(crop_name)
|
||||
if crop.nil? then
|
||||
puts "Couldn't find crop #{crop_name}"
|
||||
next
|
||||
end
|
||||
if crop.id.to_s != crop_id then
|
||||
puts "crop #{crop} has ID #{crop.id}, expected #{crop_id}"
|
||||
end
|
||||
alternate_names.split(/,\s*/).each do |an|
|
||||
puts "Adding alternate name '#{an}' to #{crop}"
|
||||
AlternateName.create(
|
||||
name: an,
|
||||
crop_id: crop.id,
|
||||
crop_id: crop_id,
|
||||
creator_id: cropbot.id
|
||||
)
|
||||
end
|
||||
|
||||
Reference in new issue
Block a user