Adding a teensy data set for sussing out the tournament logic

This commit is contained in:
Dan Buch 2012-03-08 07:51:59 -05:00
parent d7f0f6c964
commit 8fca34c7ef
4 changed files with 24 additions and 2 deletions

View File

@ -25,7 +25,7 @@ class Map < ActiveRecord::Base
FasterCSV.parse(open(csv_filename), :headers => true, FasterCSV.parse(open(csv_filename), :headers => true,
:header_converters => [:downcase, :symbol]).each do |row| :header_converters => [:downcase, :symbol]).each do |row|
map = self.find_or_initialize_by_name( map = self.find_or_initialize_by_name(
"#{row[:city]}, #{row[:country]}" "#{row[:city]}, #{row[:region]}"
) )
map.save map.save
if block_given? if block_given?

View File

@ -1,4 +1,4 @@
country,city region,city
Afghanistan,Kabul Afghanistan,Kabul
Albania,Tirane Albania,Tirane
Algeria,Algiers Algeria,Algiers

1 country region city
2 Afghanistan Kabul
3 Albania Tirane
4 Algeria Algiers

View File

@ -0,0 +1,10 @@
city,region
Omaha,Nebraska
Charlotte,North Carolina
Nashville,Tenessee
Colorado Springs,Colorado
Knoxville,Tenessee
Lexington,Kentucky
Little Rock,Arkansas
Wichita,Kansas
Cedar Rapids,Iowa
1 city region
2 Omaha Nebraska
3 Charlotte North Carolina
4 Nashville Tenessee
5 Colorado Springs Colorado
6 Knoxville Tenessee
7 Lexington Kentucky
8 Little Rock Arkansas
9 Wichita Kansas
10 Cedar Rapids Iowa

View File

@ -10,4 +10,16 @@ namespace :maps do
puts "Seeded map '#{map.name}'" puts "Seeded map '#{map.name}'"
end end
end end
desc 'Seed the maps a little bit less!'
task :miniseed => :environment do
require 'app/models/map'
csv_filename = File.expand_path(
'../../db/top-us-cities.csv', File.dirname(__FILE__)
)
Map.import(csv_filename) do |map|
puts "Seeded map '#{map.name}'"
end
end
end end