lib/logstash/inputs/mongoprofile.rb in logstash-input-mongoprofile-0.1.15 vs lib/logstash/inputs/mongoprofile.rb in logstash-input-mongoprofile-0.1.16
- old
+ new
@@ -73,15 +73,15 @@
@collection = @mongodb.collection(collection)
@client_host = client_host
end
def get_documents_by_ts(date, limit)
- @collection.find({:ts => {:$gt => DateTime.parse(date)}, :client => {:$ne => @client_host}}).limit(limit).sort(:ts => -1)
+ @collection.find({:ts => {:$gt => DateTime.parse(date) + 0.00002}, :client => {:$ne => @client_host}}).limit(limit).sort(:ts => 1)
end
def get_documents(limit)
- @collection.find({:client => {:$ne => @client_host}}).limit(limit).sort(:ts => -1)
+ @collection.find({:client => {:$ne => @client_host}}).limit(limit).sort(:ts => 1)
end
end
class ProfileCollection
def initialize(documents, parser, generate_id)
@@ -101,14 +101,16 @@
document['_id'] = generate_id.to_s
end
yield @parser.parse(document)
end
+
+ @documents = []
end
def get_last_document_date
- if @documents and @documents[-1] != nil
+ if @documents != nil and @documents[-1] != nil
@documents[-1]['ts']
else
nil
end
end
@@ -181,12 +183,12 @@
profile_collection = ProfileCollection.new(documents, @document_parser, @generate_id)
if profile_collection.get_last_document_date != nil
@last_value_store.save_last_value(profile_collection.get_last_document_date)
- end
- @logger.info('Nothing to get...')
else
+ @logger.info('Nothing to get...')
+ end
profile_collection
end
end
\ No newline at end of file