Add config file for morph for importing papers

This commit is contained in:
Lars Henrik Mai 2015-11-09 21:35:32 +01:00
parent 5bda50a753
commit ef27bce6a9
3 changed files with 6 additions and 4 deletions

1
.gitignore vendored
View file

@ -14,3 +14,4 @@
# Ignore all logfiles and tempfiles. # Ignore all logfiles and tempfiles.
/log/*.log /log/*.log
/tmp /tmp
config/morph.yml

2
config/morph.yml.example Normal file
View file

@ -0,0 +1,2 @@
development:
key: insertyourkeyhere

View file

@ -1,8 +1,7 @@
desc 'Import Paper records from setup importers' desc 'Import Paper records from setup importers'
task import_papers: :environment do task import_papers: :environment do
require 'open-uri' require 'open-uri'
Importer.all.each do |importer| api_key = Rails.application.config_for(:morph)["key"]
uri = URI.parse(importer.url) uri = "https://api.morph.io/ahx/city_council_leipzig_recent_papers/data.json?key=#{api_key}&query=select%20*%20from%20%27data%27"
Paper.import_from_json(uri.read) Paper.import_from_json(uri.read)
end end
end