mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2025-04-20 07:11:33 +02:00
Add importer model, validations to paper model
This commit is contained in:
parent
568abb631f
commit
46de026234
8 changed files with 67 additions and 13 deletions
|
@ -1,11 +1,10 @@
|
|||
namespace :import_papers do
|
||||
|
||||
desc 'Import Paper records from CSV'
|
||||
task :from_morph => :environment do |t, args|
|
||||
task :from_morph => :environment do
|
||||
require 'open-uri'
|
||||
api_key = ENV['MORPH_API_KEY']
|
||||
uri = URI.parse "https://api.morph.io/ahx/city_council_leipzig_recent_papers/data.json?key=#{api_key}&query=select%20*%20from%20%27data%27"
|
||||
puts "Download files from #{uri}…"
|
||||
Paper.import_from_json(uri.read)
|
||||
Importer.all.each do |importer|
|
||||
uri = URI.parse(importer.url)
|
||||
Paper.import_from_json(uri.read)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue