From 73096da0b673df26199fbc8e2b4e7cb1a71a943b Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Tue, 3 Feb 2015 18:47:38 +0200 Subject: [PATCH] fix data matched prefix missing --- engine/balances.go | 2 +- engine/calldesc.go | 9 +++------ engine/timespans.go | 12 ++++++++---- 3 files changed, 12 insertions(+), 11 deletions(-) diff --git a/engine/balances.go b/engine/balances.go index 84dec5693..8b5ad84d7 100644 --- a/engine/balances.go +++ b/engine/balances.go @@ -166,8 +166,8 @@ func (b *Balance) Clone() *Balance { Category: b.Category, SharedGroup: b.SharedGroup, TimingIDs: b.TimingIDs, + Timings: b.Timings, // should not be a problem with aliasing } - // clone TimingID slice } // Returns the available number of seconds for a specified credit diff --git a/engine/calldesc.go b/engine/calldesc.go index 6eda99ba6..22bc1eec2 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -317,16 +317,13 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) { return } - firstSpan.ratingInfo = cd.RatingInfos[0] + firstSpan.setRatingInfo(cd.RatingInfos[0]) if cd.TOR == MINUTES { // split on rating plans afterStart, afterEnd := false, false //optimization for multiple activation periods for _, rp := range cd.RatingInfos { if !afterStart && !afterEnd && rp.ActivationTime.Before(cd.TimeStart) { - firstSpan.ratingInfo = rp - firstSpan.MatchedSubject = rp.MatchedSubject - firstSpan.MatchedPrefix = rp.MatchedPrefix - firstSpan.MatchedDestId = rp.MatchedDestId + firstSpan.setRatingInfo(rp) } else { afterStart = true for i := 0; i < len(timespans); i++ { @@ -358,7 +355,7 @@ func (cd *CallDescriptor) splitInTimeSpans() (timespans []*TimeSpan) { } newTs := timespans[i].SplitByRateInterval(interval, cd.TOR != MINUTES) if newTs != nil { - newTs.ratingInfo = rp + newTs.setRatingInfo(rp) // insert the new timespan index := i + 1 timespans = append(timespans, nil) diff --git a/engine/timespans.go b/engine/timespans.go index ffa4122c2..1e7b812e2 100644 --- a/engine/timespans.go +++ b/engine/timespans.go @@ -274,6 +274,13 @@ func (ts *TimeSpan) getCost() float64 { } } +func (ts *TimeSpan) setRatingInfo(rp *RatingInfo) { + ts.ratingInfo = rp + ts.MatchedSubject = rp.MatchedSubject + ts.MatchedPrefix = rp.MatchedPrefix + ts.MatchedDestId = rp.MatchedDestId +} + func (ts *TimeSpan) createIncrementsSlice() { if ts.RateInterval == nil { return @@ -504,10 +511,7 @@ func (nts *TimeSpan) copyRatingInfo(ts *TimeSpan) { if ts.ratingInfo == nil { return } - nts.ratingInfo = ts.ratingInfo - nts.MatchedSubject = ts.ratingInfo.MatchedSubject - nts.MatchedPrefix = ts.ratingInfo.MatchedPrefix - nts.MatchedDestId = ts.ratingInfo.MatchedDestId + nts.setRatingInfo(ts.ratingInfo) } // returns a time for the specified second in the time span