Ejemplo n.º 1
0
//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))
}
Ejemplo n.º 2
0
//Fetch all incomming calls by did for given day
//return a json stream with calls on success otherwise http status 500
func (c Daily) IncommingDidCallsForDayByDid(day string) revel.Result {
	revel.TRACE.Printf("[Daily DID] Get incomming call by did for the given date [%s].\r\n", day)
	results := mongo.GetDidCalls(day, c.MongoDatabase)
	revel.TRACE.Printf("[Daily DID] Send to the client response of %d records.\r\n", len(results))
	return c.RenderJson(results)
}