aboutsummaryrefslogtreecommitdiffstats
path: root/lib/tasks/import.rake
Commit message (Collapse)AuthorAgeLines
* Fix the command-line CSV importer under Ruby 1.9Mark Longair2013-12-03-6/+6
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Under Ruby 1.8.7, you can parse a CSV file with the following code (Example A): require 'csv' CSV.parse('foo.csv') do |row| puts "got row: #{row.inspect}" end Rather confusingly, under Ruby 1.8.7, CSV.parse can also take a string representation of the contents of the file as its parameter, so this also works (Example B): require 'csv' CSV.parse("1,hello,red\n2,goodbye,green") do |row| puts "got row: #{row.inspect}" end However under Ruby 1.9.3, CSV.parse only expects a string representation of the contents of the CSV file, so only Example B works; Example B fails silently (interpreting the filename as a single cell CSV file, typically). The import:import_csv rake task unfortunately relied on both A and B working. This commit fixes this by adding PublicBody.import_csv_from_file, and refactoring PublicBody.import_csv to use the newly added class method, and adds a test to check for any regression in this behaviour. (This means that the usage of import_csv in the admin public body controller's import_csv action could now be changed to use PublicBody.import_csv_from_file directly from the uploaded file, which would be more efficient and cope with larger files without using lots of memory.) Fixes #1229
* Remove the confusing "time remaining" messageMark Longair2013-10-29-12/+1
| | | | | | | | | The time estimates were confusing on two counts: - The messages mixed locales - The estimates were hugely inaccurate, since the import slows down as time goes on
* Make sure that the temporary file is closed before reading from itMark Longair2013-10-29-2/+5
| | | | Thanks to Louise Crow for pointing out this problem.
* Add a rake task to import public bodies from a CSV fileMark Longair2013-10-15-0/+86
For importing a very large number of public bodies, it's mostly likely less frustrating to import them from the CSV file using this rake task instead of using the form in the admin interface. Fixes #1132