mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-22 15:48:44 +05:00
generated usagerecord id
This commit is contained in:
@@ -762,7 +762,7 @@ type UsageRecord struct {
|
||||
|
||||
func (self *UsageRecord) AsStoredCdr(timezone string) (*StoredCdr, error) {
|
||||
var err error
|
||||
storedCdr := &StoredCdr{TOR: self.TOR, ReqType: self.ReqType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category,
|
||||
storedCdr := &StoredCdr{CgrId: self.GetId(), TOR: self.TOR, ReqType: self.ReqType, Direction: self.Direction, Tenant: self.Tenant, Category: self.Category,
|
||||
Account: self.Account, Subject: self.Subject, Destination: self.Destination}
|
||||
if storedCdr.SetupTime, err = utils.ParseTimeDetectLayout(self.SetupTime, timezone); err != nil {
|
||||
return nil, err
|
||||
@@ -785,6 +785,7 @@ func (self *UsageRecord) AsStoredCdr(timezone string) (*StoredCdr, error) {
|
||||
func (self *UsageRecord) AsCallDescriptor(timezone string) (*CallDescriptor, error) {
|
||||
var err error
|
||||
cd := &CallDescriptor{
|
||||
CgrId: self.GetId(),
|
||||
TOR: self.TOR,
|
||||
Direction: self.Direction,
|
||||
Tenant: self.Tenant,
|
||||
@@ -813,3 +814,7 @@ func (self *UsageRecord) AsCallDescriptor(timezone string) (*CallDescriptor, err
|
||||
}
|
||||
return cd, nil
|
||||
}
|
||||
|
||||
func (self *UsageRecord) GetId() string {
|
||||
return utils.Sha1(self.TOR, self.ReqType, self.Direction, self.Tenant, self.Category, self.Account, self.Subject, self.Destination, self.SetupTime, self.AnswerTime, self.Usage)
|
||||
}
|
||||
|
||||
@@ -570,7 +570,7 @@ func TestUsageReqAsCD(t *testing.T) {
|
||||
Account: "1001", Subject: "1001", Destination: "1002",
|
||||
SetupTime: "2013-11-07T08:42:20Z", AnswerTime: "2013-11-07T08:42:26Z", Usage: "0.00000001",
|
||||
}
|
||||
eCD := &CallDescriptor{TOR: req.TOR, Direction: req.Direction,
|
||||
eCD := &CallDescriptor{CgrId: "9473e7b2e075d168b9da10ae957ee68fe5a217e4", TOR: req.TOR, Direction: req.Direction,
|
||||
Tenant: req.Tenant, Category: req.Category, Account: req.Account, Subject: req.Subject, Destination: req.Destination,
|
||||
TimeStart: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC), TimeEnd: time.Date(2013, 11, 7, 8, 42, 26, 0, time.UTC).Add(time.Duration(10))}
|
||||
if cd, err := req.AsCallDescriptor(""); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user