added matched subject and matched prefix to timespan

This commit is contained in:
Radu Ioan Fericean
2013-11-18 19:49:55 +02:00
parent 4b6b7758f8
commit b4f34a77cc
2 changed files with 21 additions and 16 deletions

View File

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

View File

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