From e16762fdd0e62035f1a6741feabdc3aa9e6dc3d0 Mon Sep 17 00:00:00 2001 From: Andreas Stephanides Date: Mon, 4 May 2015 13:41:07 +0200 Subject: [PATCH] crawler update --- app/controllers/crawler_controller.rb | 2 +- app/models/crawlobject.rb | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/controllers/crawler_controller.rb b/app/controllers/crawler_controller.rb index 0ceab2e..25e571a 100644 --- a/app/controllers/crawler_controller.rb +++ b/app/controllers/crawler_controller.rb @@ -3,7 +3,7 @@ class CrawlerController < ApplicationController def index authorize! :doadmin, User - @crawlobjs=Crawlobject.where(:objtype=>5) + @crawlobjs=Crawlobject.where(:objtype=>5).order(:published_at).reverse_order end def load_attachments authorize! :doadmin, User diff --git a/app/models/crawlobject.rb b/app/models/crawlobject.rb index 06993f2..2a94d52 100644 --- a/app/models/crawlobject.rb +++ b/app/models/crawlobject.rb @@ -112,8 +112,9 @@ class Crawlobject < ActiveRecord::Base def json JSON.parse(self.raw) end - def self.crawl_htu - res = JSON.parse(`python #{RAILS_ROOT}/bin/#{Rails.config.crawlconfig[5]['bin']} #{Rails.config.crawlconfig[5]['url']}`) + def self.crawl_news + cfg = Rails.application.config + res = JSON.parse(`python #{Rails.root}/bin/#{cfg.crawlconfig[5]['bin']} #{cfg.crawlconfig[5]['url']}`) res.each do |r| cc=Crawlobject.new(:raw=>r.to_json) cc.objtype=5