【发布时间】:2016-04-08 23:04:32
【问题描述】:
我使用 Dashing 来监控趋势和网站统计数据。 我创建了一个工作来检查 GooglesNews 趋势和 Twitter 趋势。
数据显示得很好,但是,它们在第一次加载时出现,然后确实进行了更多更新。有 twitter_trends.rb 的代码:
require 'nokogiri'
require 'open-uri'
url = 'http://trends24.in/france/~cloud'
data = Nokogiri::HTML(open(url))
list = data.xpath('//ol/li')
tags = list.collect do |tag|
tag.xpath('a').text
end
tags = tags.take(10)
tag_counts = Hash.new({value: 0})
SCHEDULER.every '10s' do
tag = tags.sample
tag_counts[tag] = {label: tag}
send_event('twitter_trends', {items: tag_counts.values})
end
我认为我使用了糟糕的“rufus-scheduler”来安排我的工作作业https://gist.github.com/pushmatrix/3978821#file-sample_job-rb
如何让数据定期正确更新?
【问题讨论】:
-
为什么 rufus-scheduler 不好? Romain, pourquoi qualifying-tu rufus-scheduler de mauvais?
-
我的意思是我不知道如何使用它。我不知道我的数据是如何定期更新的。 rufus-scheduler 很好:)
标签: ruby-on-rails ruby dashing rufus-scheduler