#21: added web hook for paper scraper notification

This commit is contained in:
Joerg Reichert 2016-04-03 12:14:37 +02:00
parent e3a81fea4c
commit 6b1b85c6df
2 changed files with 12 additions and 3 deletions

View file

@ -0,0 +1,9 @@
class ImportController < ApplicationController
def new_papers_callback
require 'open-uri'
api_key = Rails.application.config_for(:morph)["key"]
uri = URI.parse("https://api.morph.io/jrlover/city_council_leipzig_recent_papers/data.json?key=#{api_key}&query=select%20*%20from%20%27data%27")
Paper.import_from_json(uri.read)
render :nothing => true
end
end

View file

@ -3,11 +3,11 @@ Rails.application.routes.draw do
scope ':body' do scope ':body' do
get '/' => 'search#index', as: :search get '/' => 'search#index', as: :search
get '/:id' => 'search#show', as: :saved_search
end end
post '/auth/:provider/callback', to: 'sessions#create' scope '/a7d34068d8e22f75898ce838c0e59669bc047e46', :controller => :import do
get '/auth/browser_id', as: 'sign_in' post :new_papers_callback
end
resource :session, only: [:create, :destroy] resource :session, only: [:create, :destroy]