Nitlanguage.org
  • Nitdoc
  • popcorn
  • pop_tracker
  • PopTrackerResponseTime
  • defaultinit

init defaultinit(config: AppConfig)

popcorn :: PopTrackerResponseTime :: defaultinit

  • Doc
  • Linearization

Summary

  • Property definitions

  • popcorn$PopTrackerResponseTime$defaultinit

Property definitions

popcorn $ PopTrackerResponseTime :: defaultinit
# Return last month response time
class PopTrackerResponseTime
	super TrackerHandler

	redef fun get(req, res) do
		var limit = get_time - (3600 * 24 * 30)
		var pipe = new MongoPipeline
		pipe.match((new MongoMatch).gte("timestamp", limit))
		pipe.group((new MongoGroup("$timestamp")).
			sum("visits", 1).
			avg("response_time", "$response_time"))
		pipe.sort((new MongoMatch).eq("_id", -1))
		res.json new JsonArray.from(config.tracker_logs.collection.aggregate(pipe))
	end
end
lib/popcorn/pop_tracker.nit:186,1--200,3
Nit standard library. Version .