mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Remove use of *raw RunID out of SessionS
This commit is contained in:
@@ -217,19 +217,11 @@ func (s *Session) totalUsage() (tDur time.Duration) {
|
||||
}
|
||||
|
||||
// AsCGREvents is a method to return the Session as CGREvents
|
||||
// there will be one CGREvent for each SRun plus one *raw for EventStart
|
||||
// AsCGREvents is not thread safe since it is supposed to run by the time Session is closed
|
||||
func (s *Session) asCGREvents() (cgrEvs []*utils.CGREvent, err error) {
|
||||
cgrEvs = make([]*utils.CGREvent, len(s.SRuns)+1) // so we can gather all cdr info while under lock
|
||||
rawEv := s.EventStart.Clone()
|
||||
rawEv[utils.RunID] = utils.MetaRaw
|
||||
cgrEvs[0] = &utils.CGREvent{
|
||||
Tenant: s.Tenant,
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: rawEv,
|
||||
}
|
||||
cgrEvs = make([]*utils.CGREvent, len(s.SRuns)) // so we can gather all cdr info while under lock
|
||||
for i, sr := range s.SRuns {
|
||||
cgrEvs[i+1] = &utils.CGREvent{
|
||||
cgrEvs[i] = &utils.CGREvent{
|
||||
Tenant: s.Tenant,
|
||||
ID: utils.UUIDSha1Prefix(),
|
||||
Event: sr.Event,
|
||||
|
||||
@@ -319,12 +319,8 @@ func TestSessionAsCGREventsRawEvent(t *testing.T) {
|
||||
Tenant: "cgrates.org",
|
||||
EventStart: engine.NewMapEvent(ev),
|
||||
}
|
||||
if cgrEvs, _ := s.asCGREvents(); len(cgrEvs) != 1 {
|
||||
if cgrEvs, _ := s.asCGREvents(); len(cgrEvs) != 0 {
|
||||
t.Errorf("Expecting: 1, received: %+v", len(cgrEvs))
|
||||
} else if cgrEvs[0].Event[utils.RunID] != utils.MetaRaw {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.MetaRaw, cgrEvs[0].Event[utils.RunID])
|
||||
} else if cgrEvs[0].Event[utils.Cost] != 12.12 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 12.12, cgrEvs[0].Event[utils.Cost])
|
||||
}
|
||||
|
||||
}
|
||||
@@ -376,17 +372,12 @@ func TestSessionAsCGREvents(t *testing.T) {
|
||||
cgrEvs, err := s.asCGREvents()
|
||||
if err != nil {
|
||||
t.Error(err)
|
||||
} else if len(cgrEvs) != 2 {
|
||||
t.Errorf("Expecting: 2, received: %+v", len(cgrEvs))
|
||||
} else if len(cgrEvs) != 1 {
|
||||
t.Errorf("Expecting: 1, received: %+v", len(cgrEvs))
|
||||
}
|
||||
if cgrEvs[0].Event[utils.RunID] != utils.MetaRaw {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.MetaRaw, cgrEvs[0].Event[utils.RunID])
|
||||
} else if cgrEvs[0].Event[utils.Cost] != 12.12 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 12.12, cgrEvs[0].Event[utils.Cost])
|
||||
}
|
||||
if cgrEvs[1].Event[utils.RunID] != utils.MetaDefault {
|
||||
if cgrEvs[0].Event[utils.RunID] != utils.MetaDefault {
|
||||
t.Errorf("Expecting: %+v, received: %+v", utils.MetaRaw, cgrEvs[1].Event[utils.RunID])
|
||||
} else if cgrEvs[1].Event[utils.Cost] != 12.13 {
|
||||
} else if cgrEvs[0].Event[utils.Cost] != 12.13 {
|
||||
t.Errorf("Expecting: %+v, received: %+v", 12.13, cgrEvs[1].Event[utils.Cost])
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2654,8 +2654,7 @@ func (sS *SessionS) BiRPCv1ProcessCDR(clnt rpcclient.ClientConnector,
|
||||
CGREvent: *cgrEv,
|
||||
ArgDispatcher: cgrEvWithArgDisp.ArgDispatcher,
|
||||
}
|
||||
if mp := engine.MapEvent(cgrEv.Event); mp.GetStringIgnoreErrors(utils.RunID) != utils.MetaRaw && // check if is *raw
|
||||
unratedReqs.HasField(mp.GetStringIgnoreErrors(utils.RequestType)) { // order additional rating for unrated request types
|
||||
if mp := engine.MapEvent(cgrEv.Event); unratedReqs.HasField(mp.GetStringIgnoreErrors(utils.RequestType)) { // order additional rating for unrated request types
|
||||
argsProc.Flags = append(argsProc.Flags, fmt.Sprintf("%s:true", utils.MetaRALs))
|
||||
}
|
||||
if err = sS.cdrS.Call(utils.CDRsV1ProcessEvent,
|
||||
|
||||
Reference in New Issue
Block a user