コード例 #1
0
ファイル: broker.go プロジェクト: vassilux/revor
//Broadcaster of new data for realtime notification
//Redis queue can be used as realtime source notificateur
func processFetchEvens() {
	session, db := mongo.GetDatabase()
	timenow := time.Now()
	var currentDateString = timenow.Format(time.RFC3339) //"2015-03-21T23:59:59Z"
	didCalls := mongo.GetDidCalls(currentDateString, db)
	peerInCalls := mongo.GetPeerInCalls(currentDateString, db)
	peerOutCalls := mongo.GetPeerOutCalls(currentDateString, db)
	peerInCallsDisp := mongo.GetPeerDispositionByDay(currentDateString, "in", "", db)
	peerOutCallsDisp := mongo.GetPeerDispositionByDay(currentDateString, "out", "", db)
	results := bson.M{
		"didCalls":         didCalls,
		"peerInCalls":      peerInCalls,
		"peerOutCalls":     peerOutCalls,
		"peerInCallsDisp":  peerInCallsDisp,
		"peerOutCallsDisp": peerOutCallsDisp,
	}
	data, err := json.Marshal(results)
	if err == nil {
		MyBroker.Messages <- fmt.Sprintf("%s", data)
	}
	if session != nil {
		session.Close()
	}
	revel.TRACE.Printf("Broadcast message [%s] to %d clients", data, len(MyBroker.Clients))
}
コード例 #2
0
ファイル: daily.go プロジェクト: vassilux/revor
//Fetch all datas for peers
//return a json stream with calls on success otherwise http status 500
func (c Daily) PeersDatas(day string) revel.Result {
	revel.TRACE.Printf("[Daily PEERSDATAS] Get incomming call for the given date [%s].\r\n", day)
	results := bson.M{}
	inCalls := mongo.GetPeerInCalls(day, c.MongoDatabase)
	outCalls := mongo.GetPeerOutCalls(day, c.MongoDatabase)
	hourlyInCalls := mongo.GetPeerInCallsByHours(day, c.MongoDatabase)
	hourlyOutCalls := mongo.GetPeerOutCallsByHours(day, c.MongoDatabase)
	results["inCalls"] = inCalls
	results["outCalls"] = outCalls
	results["hourlyInCalls"] = hourlyInCalls
	results["hourlyOutCalls"] = hourlyOutCalls
	revel.TRACE.Printf("[Daily PEERSDATAS] Send to the client response of %d records.\r\n", len(results))
	return c.RenderJson(results)
}