parent
cda855a026
commit
c813a2ef2e
@ -0,0 +1,21 @@
|
|||||||
|
# encoding: utf-8
|
||||||
|
require 'fileutils'
|
||||||
|
namespace :cartodb do
|
||||||
|
desc 'Import a file to CartoDB'
|
||||||
|
task :import, [:username, :filepath] => [:environment] do |task, args|
|
||||||
|
user = User.where(username: args[:username]).first
|
||||||
|
filepath = File.expand_path(args[:filepath])
|
||||||
|
|
||||||
|
data_import = DataImport.create(
|
||||||
|
:user_id => user.id,
|
||||||
|
:data_source => filepath,
|
||||||
|
:updated_at => Time.now,
|
||||||
|
:append => false
|
||||||
|
)
|
||||||
|
data_import.values[:data_source] = filepath
|
||||||
|
|
||||||
|
data_import.run_import!
|
||||||
|
puts data_import.log
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
@ -0,0 +1,8 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
if [ -z "$2" ]; then
|
||||||
|
echo "Usage: script/import <username> <path to file>"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
bundle exec rake cartodb:import[$1,$2]
|
||||||
|
if test $? -ne 0; then exit 1; fi
|
Loading…
Reference in new issue