mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Merge branch 'master' of https://github.com/cgrates/cgrates
This commit is contained in:
@@ -63,6 +63,9 @@ func (cc *CallCost) GetDuration() (td time.Duration) {
|
||||
}
|
||||
|
||||
func (cc *CallCost) UpdateRatedUsage() time.Duration {
|
||||
if cc == nil {
|
||||
return 0
|
||||
}
|
||||
totalDuration := cc.GetDuration()
|
||||
cc.RatedUsage = totalDuration.Seconds()
|
||||
return totalDuration
|
||||
|
||||
@@ -175,6 +175,9 @@ func (self *CdrServer) processCdr(cdr *CDR) (err error) {
|
||||
cdr.RunID = utils.MetaRaw
|
||||
}
|
||||
if self.cgrCfg.CDRSStoreCdrs { // Store RawCDRs, this we do sync so we can reply with the status
|
||||
if cdr.CostDetails != nil {
|
||||
cdr.CostDetails.UpdateRatedUsage()
|
||||
}
|
||||
if err := self.cdrDb.SetCDR(cdr, false); err != nil { // Only original CDR stored in primary table, no derived
|
||||
utils.Logger.Err(fmt.Sprintf("<CDRS> Storing primary CDR %+v, got error: %s", cdr, err.Error()))
|
||||
return err // Error is propagated back and we don't continue processing the CDR if we cannot store it
|
||||
@@ -231,6 +234,9 @@ func (self *CdrServer) rateStoreStatsReplicate(cdr *CDR, sendToStats bool) error
|
||||
}
|
||||
if self.cgrCfg.CDRSStoreCdrs { // Store CDRs
|
||||
// Store RatedCDR
|
||||
if cdr.CostDetails != nil {
|
||||
cdr.CostDetails.UpdateRatedUsage()
|
||||
}
|
||||
if err := self.cdrDb.SetCDR(cdr, true); err != nil {
|
||||
utils.Logger.Err(fmt.Sprintf("<CDRS> Storing rated CDR %+v, got error: %s", cdr, err.Error()))
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user