From 1984934ae31524c43d57193e6ecf019641a452d5 Mon Sep 17 00:00:00 2001 From: TeoV Date: Wed, 28 Feb 2018 06:33:59 -0500 Subject: [PATCH] CDRS sendind rated cdr to statS --- engine/balances.go | 26 +++++++++++++------------- engine/cdrs.go | 2 +- engine/stats.go | 30 +++++++++++++++--------------- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/engine/balances.go b/engine/balances.go index 863c55bf7..d64f20c7d 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -782,20 +782,20 @@ func (bc Balances) SaveDirtyBalances(acc *Account) { } accountId = b.account.ID acntTnt := utils.NewTenantID(accountId) + thEv := &ArgsProcessEvent{ + CGREvent: utils.CGREvent{ + Tenant: acntTnt.Tenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + utils.EventType: utils.BalanceUpdate, + utils.EventSource: utils.AccountService, + utils.Account: acntTnt.ID, + utils.BalanceID: b.ID, + utils.Units: b.Value}}} + if !b.ExpirationDate.IsZero() { + thEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339) + } if thresholdS != nil { - thEv := &ArgsProcessEvent{ - CGREvent: utils.CGREvent{ - Tenant: acntTnt.Tenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - utils.EventType: utils.BalanceUpdate, - utils.EventSource: utils.AccountService, - utils.Account: acntTnt.ID, - utils.BalanceID: b.ID, - utils.Units: b.Value}}} - if !b.ExpirationDate.IsZero() { - thEv.Event[utils.ExpiryTime] = b.ExpirationDate.Format(time.RFC3339) - } var hits int if err := thresholdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil && err.Error() != utils.ErrNotFound.Error() { diff --git a/engine/cdrs.go b/engine/cdrs.go index 5e8df8783..ef309091c 100644 --- a/engine/cdrs.go +++ b/engine/cdrs.go @@ -222,7 +222,7 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) { } if self.rals != nil && !cdr.Rated { // CDRs not rated will be processed by Rating go self.deriveRateStoreStatsReplicate(cdr, self.cgrCfg.CDRSStoreCdrs, - self.cdrstats != nil, len(self.cgrCfg.CDRSOnlineCDRExports) != 0) + true, len(self.cgrCfg.CDRSOnlineCDRExports) != 0) } return nil } diff --git a/engine/stats.go b/engine/stats.go index 502176c40..c10d19b21 100644 --- a/engine/stats.go +++ b/engine/stats.go @@ -232,22 +232,22 @@ func (sS *StatService) processEvent(ev *utils.CGREvent) (err error) { sS.ssqMux.Unlock() } } + var thIDs []string + if len(sq.sqPrfl.ThresholdIDs) != 0 { + thIDs = sq.sqPrfl.ThresholdIDs + } + thEv := &ArgsProcessEvent{ + ThresholdIDs: thIDs, + CGREvent: utils.CGREvent{ + Tenant: sq.Tenant, + ID: utils.GenUUID(), + Event: map[string]interface{}{ + utils.EventType: utils.StatUpdate, + utils.StatID: sq.ID}}} + for metricID, metric := range sq.SQMetrics { + thEv.Event[metricID] = metric.GetValue() + } if sS.thdS != nil { - var thIDs []string - if len(sq.sqPrfl.ThresholdIDs) != 0 { - thIDs = sq.sqPrfl.ThresholdIDs - } - thEv := &ArgsProcessEvent{ - ThresholdIDs: thIDs, - CGREvent: utils.CGREvent{ - Tenant: sq.Tenant, - ID: utils.GenUUID(), - Event: map[string]interface{}{ - utils.EventType: utils.StatUpdate, - utils.StatID: sq.ID}}} - for metricID, metric := range sq.SQMetrics { - thEv.Event[metricID] = metric.GetValue() - } var hits int if err := sS.thdS.Call(utils.ThresholdSv1ProcessEvent, thEv, &hits); err != nil && err.Error() != utils.ErrNotFound.Error() {