lib/logstash/inputs/mongoprofile.rb in logstash-input-mongoprofile-0.1.4 vs lib/logstash/inputs/mongoprofile.rb in logstash-input-mongoprofile-0.1.5

- old
+ new

@@ -71,21 +71,26 @@ @collection = @mongodb.collection(collection) @client_host = client_host end def get_documents_by_ts(date, limit) - @collection.find({:ts => {:$gt => date}, :client => {:$ne => @client_host}}).limit(limit) + @collection.find({:ts => {:$gt => date}, :client => {:$ne => @client_host}}).limit(limit).sort(:ts => -1) end def get_documents(limit) - @collection.find({:client => {:$ne => @client_host}}).limit(limit) + @collection.find({:client => {:$ne => @client_host}}).limit(limit).sort(:ts => -1) end end class ProfileCollection def initialize(documents, parser) - @documents = documents + @documents = [] + + documents.each do |document| + @documents.push(document) + end + @parser = parser end def each @documents.each do |document| @@ -150,11 +155,13 @@ def get_next_events last_date_value = @last_value_store.get_last_value if last_date_value == '' + @logger.info('Getting documents from mongo first time') documents = @mongo_accessor.get_documents(@limit) else + @logger.info("Getting documents from mongo start at #{last_date_value}") documents = @mongo_accessor.get_documents_by_ts(last_date_value, @limit) end profile_collection = ProfileCollection.new(documents, @document_parser) \ No newline at end of file