Remove superfluous* error-checks from load_altnames

* /me crosses fingers...
This commit is contained in:
Miles Gould committed 2014-10-19 22:19:41 +01:00
1 parent 36be5e9533
commit 06a4fcab71
2 files changed
+3 -12

No files matched your search

+1 -2
View File
@@ -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 "
1 Id 1 Name achiote Alternate names (comma separated) aploppas, uruku
Id Name Alternate names (comma separated)
1 1 1 achiote achiote aploppas, uruku aploppas, uruku
2 2 2 ackee ackee achee, ackee apple, akee achee, ackee apple, akee
3 267 267 acorn squash acorn squash pepper squash, Des Moines squash pepper squash, Des Moines squash
379 Palmers Amaranth Palmers Amaranth Palmer amaranth, Palmer's pigweed, carelessweed Palmer amaranth, Palmer's pigweed, carelessweed
380 Red-Root Amaranth Red-Root Amaranth redroot pigweed, red-rooted pigweed, common amaranth, pigweed amaranth, common tumbleweed redroot pigweed, red-rooted pigweed, common amaranth, pigweed amaranth, common tumbleweed
381 Spiny Amaranth Spiny Amaranth prickly amaranth, thorny amaranth prickly amaranth, thorny amaranth
382 Tandaljo Tandaljo Tandalja bhaji, callaloo, Joseph's coat Tandalja bhaji, callaloo, Joseph's coat
+2 -10
View File
@@ -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