From b4f34a77ccbf4f57eaa1bd71681f0f884152d25e Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 18 Nov 2013 19:49:55 +0200 Subject: [PATCH] added matched subject and matched prefix to timespan --- engine/calldesc.go | 14 ++++++-------- engine/timespans.go | 23 +++++++++++++++-------- 2 files changed, 21 insertions(+), 16 deletions(-) diff --git a/engine/calldesc.go b/engine/calldesc.go index dcae9b82e..7ca9c5bfa 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -284,6 +284,8 @@ func (cd *CallDescriptor) splitInTimeSpans(firstSpan *TimeSpan) (timespans []*Ti for _, rp := range cd.RatingInfos { if !afterStart && !afterEnd && rp.ActivationTime.Before(cd.TimeStart) { firstSpan.ratingInfo = rp + firstSpan.MatchedSubject = rp.MatchedSubject + firstSpan.MatchedPrefix = rp.MatchedPrefix } else { afterStart = true for i := 0; i < len(timespans); i++ { @@ -399,14 +401,10 @@ func (cd *CallDescriptor) GetCost() (*CallCost, error) { cost = utils.Round(cost, roundingDecimals, roundingMethod) //startIndex := len(fmt.Sprintf("%s:%s:%s:", cd.Direction, cd.Tenant, cd.TOR)) cc := &CallCost{ - Direction: cd.Direction, - TOR: cd.TOR, - Tenant: cd.Tenant, - // TODO, FIXME: find out where to put matched subject - //Subject: matchedSubject[startIndex:], - Account: cd.Account, - // TODO, FIXME: find out where to put matched prfixes - //Destination: strings.Join(destPrefix, ";"), + Direction: cd.Direction, + TOR: cd.TOR, + Tenant: cd.Tenant, + Account: cd.Account, Cost: cost, ConnectFee: connectionFee, Timespans: timespans} diff --git a/engine/timespans.go b/engine/timespans.go index cb82fdb7c..50ad35713 100644 --- a/engine/timespans.go +++ b/engine/timespans.go @@ -28,13 +28,14 @@ import ( A unit in which a call will be split that has a specific price related interval attached to it. */ type TimeSpan struct { - TimeStart, TimeEnd time.Time - Cost float64 - ratingInfo *RatingInfo - RateInterval *RateInterval - CallDuration time.Duration // the call duration so far till TimeEnd - overlapped bool // mark a timespan as overlapped by an expanded one - Increments Increments + TimeStart, TimeEnd time.Time + Cost float64 + ratingInfo *RatingInfo + RateInterval *RateInterval + CallDuration time.Duration // the call duration so far till TimeEnd + overlapped bool // mark a timespan as overlapped by an expanded one + Increments Increments + MatchedSubject, MatchedPrefix string } type Increment struct { @@ -259,7 +260,13 @@ func (ts *TimeSpan) SplitByRatingPlan(rp *RatingInfo) (newTs *TimeSpan) { if !ts.Contains(rp.ActivationTime) { return nil } - newTs = &TimeSpan{TimeStart: rp.ActivationTime, TimeEnd: ts.TimeEnd, ratingInfo: rp} + newTs = &TimeSpan{ + TimeStart: rp.ActivationTime, + TimeEnd: ts.TimeEnd, + ratingInfo: rp, + MatchedSubject: rp.MatchedSubject, + MatchedPrefix: rp.MatchedPrefix, + } newTs.CallDuration = ts.CallDuration ts.TimeEnd = rp.ActivationTime ts.SetNewCallDuration(newTs)