|
@@ -34,6 +34,23 @@ module Agents
|
|
|
}
|
|
|
end
|
|
|
|
|
|
+ event_description <<-MD
|
|
|
+ Events look like:
|
|
|
+
|
|
|
+ {
|
|
|
+ "id": "829f845279611d7925146725317b868d",
|
|
|
+ "date_published": "2014-09-11 01:30:00 -0700",
|
|
|
+ "last_updated": "Thu, 11 Sep 2014 01:30:00 -0700",
|
|
|
+ "urls": [ "http://example.com/..." ],
|
|
|
+ "description": "Some description",
|
|
|
+ "content": "Some content",
|
|
|
+ "title": "Some title",
|
|
|
+ "authors": [ ... ],
|
|
|
+ "categories": [ ... ]
|
|
|
+ }
|
|
|
+
|
|
|
+ MD
|
|
|
+
|
|
|
def working?
|
|
|
event_created_within?((interpolated['expected_update_period_in_days'].presence || 10).to_i) && !recent_error_logs?
|
|
|
end
|
|
@@ -55,10 +72,11 @@ module Agents
|
|
|
feed.clean! if interpolated['clean'] == 'true'
|
|
|
created_event_count = 0
|
|
|
feed.entries.each do |entry|
|
|
|
- if check_and_track(entry.id)
|
|
|
+ entry_id = get_entry_id(entry)
|
|
|
+ if check_and_track(entry_id)
|
|
|
created_event_count += 1
|
|
|
create_event(:payload => {
|
|
|
- :id => entry.id,
|
|
|
+ :id => entry_id,
|
|
|
:date_published => entry.date_published,
|
|
|
:last_updated => entry.last_updated,
|
|
|
:urls => entry.urls,
|
|
@@ -78,6 +96,10 @@ module Agents
|
|
|
|
|
|
protected
|
|
|
|
|
|
+ def get_entry_id(entry)
|
|
|
+ entry.id.presence || Digest::MD5.hexdigest(entry.content)
|
|
|
+ end
|
|
|
+
|
|
|
def check_and_track(entry_id)
|
|
|
memory['seen_ids'] ||= []
|
|
|
if memory['seen_ids'].include?(entry_id)
|