mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-23 08:08:45 +05:00
added call descriptor runid
This commit is contained in:
@@ -153,7 +153,8 @@ type CallDescriptor struct {
|
||||
MaxRate float64
|
||||
MaxRateUnit time.Duration
|
||||
MaxCostSoFar float64
|
||||
CgrId string
|
||||
CgrID string
|
||||
RunID string
|
||||
account *Account
|
||||
testCallcost *CallCost // testing purpose only!
|
||||
}
|
||||
|
||||
@@ -186,7 +186,7 @@ func (rs *Responder) FakeDebit(arg *CallDescriptor, reply *CallCost) (err error)
|
||||
}
|
||||
|
||||
func (rs *Responder) MaxDebit(arg *CallDescriptor, reply *CallCost) (err error) {
|
||||
if item, err := rs.getCache().Get(utils.MAX_DEBIT_CACHE_PREFIX + arg.CgrId); err == nil && item != nil {
|
||||
if item, err := rs.getCache().Get(utils.MAX_DEBIT_CACHE_PREFIX + arg.CgrID + arg.RunID); err == nil && item != nil {
|
||||
*reply = *(item.Value.(*CallCost))
|
||||
return item.Err
|
||||
}
|
||||
@@ -216,7 +216,7 @@ func (rs *Responder) MaxDebit(arg *CallDescriptor, reply *CallCost) (err error)
|
||||
} else {
|
||||
r, e := arg.MaxDebit()
|
||||
if e != nil {
|
||||
rs.getCache().Cache(utils.MAX_DEBIT_CACHE_PREFIX+arg.CgrId, &cache2go.CacheItem{
|
||||
rs.getCache().Cache(utils.MAX_DEBIT_CACHE_PREFIX+arg.CgrID+arg.RunID, &cache2go.CacheItem{
|
||||
Err: e,
|
||||
})
|
||||
return e
|
||||
@@ -224,7 +224,7 @@ func (rs *Responder) MaxDebit(arg *CallDescriptor, reply *CallCost) (err error)
|
||||
*reply = *r
|
||||
}
|
||||
}
|
||||
rs.getCache().Cache(utils.MAX_DEBIT_CACHE_PREFIX+arg.CgrId, &cache2go.CacheItem{
|
||||
rs.getCache().Cache(utils.MAX_DEBIT_CACHE_PREFIX+arg.CgrID+arg.RunID, &cache2go.CacheItem{
|
||||
Value: reply,
|
||||
Err: err,
|
||||
})
|
||||
@@ -232,7 +232,7 @@ func (rs *Responder) MaxDebit(arg *CallDescriptor, reply *CallCost) (err error)
|
||||
}
|
||||
|
||||
func (rs *Responder) RefundIncrements(arg *CallDescriptor, reply *float64) (err error) {
|
||||
if item, err := rs.getCache().Get(utils.REFUND_INCR_CACHE_PREFIX + arg.CgrId); err == nil && item != nil {
|
||||
if item, err := rs.getCache().Get(utils.REFUND_INCR_CACHE_PREFIX + arg.CgrID + arg.RunID); err == nil && item != nil {
|
||||
*reply = *(item.Value.(*float64))
|
||||
return item.Err
|
||||
}
|
||||
@@ -261,7 +261,7 @@ func (rs *Responder) RefundIncrements(arg *CallDescriptor, reply *float64) (err
|
||||
} else {
|
||||
*reply, err = arg.RefundIncrements()
|
||||
}
|
||||
rs.getCache().Cache(utils.REFUND_INCR_CACHE_PREFIX+arg.CgrId, &cache2go.CacheItem{
|
||||
rs.getCache().Cache(utils.REFUND_INCR_CACHE_PREFIX+arg.CgrID+arg.RunID, &cache2go.CacheItem{
|
||||
Value: reply,
|
||||
Err: err,
|
||||
})
|
||||
@@ -358,7 +358,8 @@ func (rs *Responder) GetDerivedMaxSessionTime(ev *CDR, reply *float64) error {
|
||||
usage = config.CgrConfig().MaxCallDuration
|
||||
}
|
||||
cd := &CallDescriptor{
|
||||
CgrId: ev.GetCgrId(rs.Timezone),
|
||||
CgrID: ev.GetCgrId(rs.Timezone),
|
||||
RunID: ev.RunID,
|
||||
TOR: ev.ToR,
|
||||
Direction: ev.GetDirection(dc.DirectionField),
|
||||
Tenant: ev.GetTenant(dc.TenantField),
|
||||
@@ -445,7 +446,8 @@ func (rs *Responder) GetSessionRuns(ev *CDR, sRuns *[]*SessionRun) error {
|
||||
return errors.New("Error parsing answer event end time")
|
||||
}
|
||||
cd := &CallDescriptor{
|
||||
CgrId: ev.GetCgrId(rs.Timezone),
|
||||
CgrID: ev.GetCgrId(rs.Timezone),
|
||||
RunID: ev.RunID,
|
||||
TOR: ev.ToR,
|
||||
Direction: ev.GetDirection(dc.DirectionField),
|
||||
Tenant: ev.GetTenant(dc.TenantField),
|
||||
|
||||
@@ -151,13 +151,13 @@ func TestResponderGetSessionRuns(t *testing.T) {
|
||||
sesRuns := make([]*SessionRun, 0)
|
||||
eSRuns := []*SessionRun{
|
||||
&SessionRun{DerivedCharger: extra1DC,
|
||||
CallDescriptor: &CallDescriptor{CgrId: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), Direction: "*out", Category: "0",
|
||||
CallDescriptor: &CallDescriptor{CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), RunID: "*default", Direction: "*out", Category: "0",
|
||||
Tenant: "vdf", Subject: "rif", Account: "minitsboy", Destination: "0256", TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC), TOR: utils.VOICE, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}},
|
||||
&SessionRun{DerivedCharger: extra2DC,
|
||||
CallDescriptor: &CallDescriptor{CgrId: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), Direction: "*out", Category: "call",
|
||||
CallDescriptor: &CallDescriptor{CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), RunID: "*default", Direction: "*out", Category: "call",
|
||||
Tenant: "vdf", Subject: "ivo", Account: "ivo", Destination: "1002", TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC), TOR: utils.VOICE, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}},
|
||||
&SessionRun{DerivedCharger: dfDC,
|
||||
CallDescriptor: &CallDescriptor{CgrId: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), Direction: "*out", Category: "call",
|
||||
CallDescriptor: &CallDescriptor{CgrID: utils.Sha1("dsafdsaf", time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).String()), RunID: "*default", Direction: "*out", Category: "call",
|
||||
Tenant: "vdf", Subject: "dan2", Account: "dan2", Destination: "1002", TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 36, 0, time.UTC), TOR: utils.VOICE, ExtraFields: map[string]string{"field_extr1": "val_extr1", "fieldextr2": "valextr2"}}}}
|
||||
if err := rsponder.GetSessionRuns(cdr, &sesRuns); err != nil {
|
||||
t.Error(err)
|
||||
|
||||
Reference in New Issue
Block a user