Exemple #1
0
func (apier *ApierV2) CountCdrs(attrs utils.RpcCdrsFilter, reply *int64) error {
	cdrsFltr, err := attrs.AsCdrsFilter(apier.Config.DefaultTimezone)
	if err != nil {
		return utils.NewErrServerError(err)
	}
	cdrsFltr.Count = true
	if _, count, err := apier.CdrDb.GetStoredCdrs(cdrsFltr); err != nil {
		return utils.NewErrServerError(err)
	} else {
		*reply = count
	}
	return nil
}
Exemple #2
0
// Retrieves CDRs based on the filters
func (apier *ApierV2) GetCdrs(attrs utils.RpcCdrsFilter, reply *[]*engine.ExternalCdr) error {
	cdrsFltr, err := attrs.AsCdrsFilter(apier.Config.DefaultTimezone)
	if err != nil {
		return utils.NewErrServerError(err)
	}
	if cdrs, _, err := apier.CdrDb.GetStoredCdrs(cdrsFltr); err != nil {
		return utils.NewErrServerError(err)
	} else if len(cdrs) == 0 {
		*reply = make([]*engine.ExternalCdr, 0)
	} else {
		for _, cdr := range cdrs {
			*reply = append(*reply, cdr.AsExternalCdr())
		}
	}
	return nil
}