예제 #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)
}
예제 #3
0
파일: daily.go 프로젝트: vassilux/revor
//Fetch all incomming calls for given day
//return a json stream with calls on success otherwise http status 500
func (c Daily) IncommingCallsByDay(day string) revel.Result {
	revel.TRACE.Printf("[Daily] Get incomming call by day for the date [%s].\r\n", day)
	results := mongo.GetPeerInCalls(day, c.MongoDatabase)
	revel.TRACE.Printf("[Daily] send to the client response of %d records.\r\n", len(results))
	return c.RenderJson(results)
}