Skip to content

Instantly share code, notes, and snippets.

/ruby.rb Secret

Created April 24, 2015 11:13
Show Gist options
  • Save anonymous/e104f6e7a9f1f6b808dc to your computer and use it in GitHub Desktop.
Save anonymous/e104f6e7a9f1f6b808dc to your computer and use it in GitHub Desktop.
[OUTPUT]
Fri Apr 24 13:10:50.139 [conn1] command api_profiler.$cmd command: { aggregate: "endpointresults", pipeline: [ { $match: { endpoint: ObjectId('5539efe4cee2b027063c1780'), created: { $gt: 604799.999956 } } }, { $group: { _id: "$endpoint", avg: { $avg: "$duration" } } } ] } ntoreturn:1 keyUpdates:0 locks(micros) r:7247 reslen:50 7ms
[CODE]
time = DateTime.now
fromTime = time.to_time - 7.days.ago
avg = Endpointresult.collection.aggregate([
{"$match" => {"endpoint" => self._id, 'created' => {'$gt' => fromTime}}},
{"$group" => {"_id" => "$endpoint", "avg" => {"$avg" => "$duration"}}}
])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment