Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

move event import to the migration

  • Loading branch information...
commit abb5cd1ab872b3d82c5cc02a3eac532ef83f614e 1 parent 9985e55
@jasonadamyoung jasonadamyoung authored
View
11 app/models/conference.rb
@@ -193,6 +193,17 @@ def import_sessions_from_csv_data(csv_data_string)
end
+ def self.get_csv_data(csv_data_url)
+ response = RestClient.get(csv_data_url)
+ if(!response.code == 200)
+ return nil
+ end
+ csvdata = response.to_str
+ # force utf8 - for some reason it's coming across as ASCII-8BIT
+ csvdata.force_encoding('UTF-8')
+ csvdata
+ end
+
View
16 db/migrate/20120903153951_add_conference_data.rb
@@ -18,6 +18,22 @@ def up
:is_virtual => false)
+ # conference events
+ if(csv_data = Conference.get_csv_data('https://docs.google.com/spreadsheet/pub?key=0AiKHgDf9UwV6dEd4WW5fb2tpc0paV3h5bmJ2TkV2Mmc&single=true&gid=0&output=csv'))
+ results = nexc2012.import_sessions_from_csv_data(csv_data)
+ say "Imported #{results[:created_count]} events"
+ if(results[:error_count] > 0)
+ puts "Unable to import #{results[:error_count]} events, showing titles and errors"
+ results[:error_titles].keys.each do |title|
+ say " Title: #{title}"
+ say " Errors: #{results[:error_titles][title]}"
+ end
+ end
+ else
+ say "Unable to download nexc2012 data"
+ end
+
+
# evaluation questions
EvaluationQuestion.reset_column_information
EvaluationQuestion.create(conference: nexc2012,
View
50 script/importer.rb
@@ -29,33 +29,33 @@ def get_csv_data(csv_data_url)
csvdata
end
- def get_nexc_data()
- get_csv_data('https://docs.google.com/spreadsheet/pub?key=0AiKHgDf9UwV6dEd4WW5fb2tpc0paV3h5bmJ2TkV2Mmc&single=true&gid=0&output=csv')
- end
+ # def get_nexc_data()
+ # get_csv_data('https://docs.google.com/spreadsheet/pub?key=0AiKHgDf9UwV6dEd4WW5fb2tpc0paV3h5bmJ2TkV2Mmc&single=true&gid=0&output=csv')
+ # end
end
- desc "nexc_import", "Download and import the NeXC session data as events"
- method_option :environment,:default => 'development', :aliases => "-e", :desc => "Rails environment"
- def nexc_import
- load_rails(options[:environment])
- if(csv_data = get_nexc_data)
- if(conference = Conference.find_by_hashtag('nexc2012'))
- results = conference.import_sessions_from_csv_data(csv_data)
- puts "Imported #{results[:created_count]} events"
- if(results[:error_count] > 0)
- puts "Unable to import #{results[:error_count]} events, showing titles and errors"
- results[:error_titles].keys.each do |title|
- puts " Title: #{title}"
- puts " Errors: #{results[:error_titles][title]}"
- end
- end
- else
- puts "Unable to find nexc2012 conference"
- end
- else
- puts "Unable to download nexc2012 data"
- end
- end
+ # desc "nexc_import", "Download and import the NeXC session data as events"
+ # method_option :environment,:default => 'development', :aliases => "-e", :desc => "Rails environment"
+ # def nexc_import
+ # load_rails(options[:environment])
+ # if(csv_data = get_nexc_data)
+ # if(conference = Conference.find_by_hashtag('nexc2012'))
+ # results = conference.import_sessions_from_csv_data(csv_data)
+ # puts "Imported #{results[:created_count]} events"
+ # if(results[:error_count] > 0)
+ # puts "Unable to import #{results[:error_count]} events, showing titles and errors"
+ # results[:error_titles].keys.each do |title|
+ # puts " Title: #{title}"
+ # puts " Errors: #{results[:error_titles][title]}"
+ # end
+ # end
+ # else
+ # puts "Unable to find nexc2012 conference"
+ # end
+ # else
+ # puts "Unable to download nexc2012 data"
+ # end
+ # end
end
Please sign in to comment.
Something went wrong with that request. Please try again.