fix data matched prefix missing

This commit is contained in:
Radu Ioan Fericean
2015-02-03 18:47:38 +02:00
parent 490bd9d573
commit 73096da0b6
3 changed files with 12 additions and 11 deletions

View File

@@ -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

View File

@@ -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)

View File

@@ -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