From ef27bce6a98992fa6c927c22b811b5efe29910a1 Mon Sep 17 00:00:00 2001 From: Lars Henrik Mai Date: Mon, 9 Nov 2015 21:35:32 +0100 Subject: [PATCH] Add config file for morph for importing papers --- .gitignore | 1 + config/morph.yml.example | 2 ++ lib/tasks/import_papers.rake | 7 +++---- 3 files changed, 6 insertions(+), 4 deletions(-) create mode 100644 config/morph.yml.example diff --git a/.gitignore b/.gitignore index 6a502e9..70851bc 100644 --- a/.gitignore +++ b/.gitignore @@ -14,3 +14,4 @@ # Ignore all logfiles and tempfiles. /log/*.log /tmp +config/morph.yml diff --git a/config/morph.yml.example b/config/morph.yml.example new file mode 100644 index 0000000..6a37aa4 --- /dev/null +++ b/config/morph.yml.example @@ -0,0 +1,2 @@ +development: + key: insertyourkeyhere diff --git a/lib/tasks/import_papers.rake b/lib/tasks/import_papers.rake index 28f77b0..d5ffd52 100644 --- a/lib/tasks/import_papers.rake +++ b/lib/tasks/import_papers.rake @@ -1,8 +1,7 @@ desc 'Import Paper records from setup importers' task import_papers: :environment do require 'open-uri' - Importer.all.each do |importer| - uri = URI.parse(importer.url) - Paper.import_from_json(uri.read) - end + api_key = Rails.application.config_for(:morph)["key"] + 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) end