Changed cgrid hash to build using SetupTime.UTC()

This commit is contained in:
DanB
2014-07-09 12:31:45 +02:00
parent 090f7706e8
commit b5f26c00b8
5 changed files with 10 additions and 5 deletions

View File

@@ -75,7 +75,7 @@ type FSCdr struct {
func (fsCdr FSCdr) getCgrId() string {
setupTime, _ := utils.ParseTimeDetectLayout(fsCdr.vars[FS_SETUP_TIME])
return utils.Sha1(fsCdr.vars[FS_UUID], setupTime.String())
return utils.Sha1(fsCdr.vars[FS_UUID], setupTime.UTC().String())
}
func (fsCdr FSCdr) getExtraFields() map[string]string {

View File

@@ -54,7 +54,7 @@ func TestCDRFields(t *testing.T) {
}
setupTime, _ := utils.ParseTimeDetectLayout(fsCdr.vars[FS_SETUP_TIME])
answerTime, _ := utils.ParseTimeDetectLayout(fsCdr.vars[FS_ANSWER_TIME])
expctStoredCdr := &utils.StoredCdr{CgrId: utils.Sha1("01df56f4-d99a-4ef6-b7fe-b924b2415b7f", setupTime.String()), TOR: utils.VOICE, AccId: "01df56f4-d99a-4ef6-b7fe-b924b2415b7f",
expctStoredCdr := &utils.StoredCdr{CgrId: utils.Sha1("01df56f4-d99a-4ef6-b7fe-b924b2415b7f", setupTime.UTC().String()), TOR: utils.VOICE, AccId: "01df56f4-d99a-4ef6-b7fe-b924b2415b7f",
CdrHost: "127.0.0.1", CdrSource: "freeswitch_json", Direction: "*out", Category: "call", ReqType: utils.RATED, Tenant: "ipbx.itsyscom.com", Account: "dan", Subject: "dan",
Destination: "+4986517174963", SetupTime: setupTime, AnswerTime: answerTime, Usage: time.Duration(4) * time.Second,
ExtraFields: map[string]string{"sip_user_agent": "Jitsi2.2.4603.9615Linux"}, Cost: -1}

View File

@@ -137,7 +137,7 @@ func (fsev FSEvent) GetCategory(fieldName string) string {
}
func (fsev FSEvent) GetCgrId() string {
setupTime, _ := fsev.GetSetupTime(utils.META_DEFAULT)
return utils.Sha1(fsev[UUID], setupTime.String())
return utils.Sha1(fsev[UUID], setupTime.UTC().String())
}
func (fsev FSEvent) GetUUID() string {
return fsev[UUID]
@@ -251,6 +251,7 @@ func (fsev FSEvent) ParseEventValue(rsrFld *utils.RSRField) string {
}
func (fsev FSEvent) PassesFieldFilter(fieldFilter *utils.RSRField) (bool, string) {
// Keep in sync (or merge) with StoredCdr.PassesFieldFielter()
if fieldFilter == nil {
return true, ""
}

View File

@@ -504,7 +504,7 @@ func TestParseEventValue(t *testing.T) {
cfg, _ = config.NewDefaultCGRConfig()
config.SetCgrConfig(cfg)
ev := new(FSEvent).New(hangupEv)
if cgrid := ev.ParseEventValue(&utils.RSRField{Id: utils.CGRID}); cgrid != "8b1ca78a9bbaa42c811e60b974188197c425dbe7" {
if cgrid := ev.ParseEventValue(&utils.RSRField{Id: utils.CGRID}); cgrid != "873e5bf7903978f305f7d8fed3f92f968cf82873" {
t.Error("Unexpected cgrid parsed", cgrid)
}
if tor := ev.ParseEventValue(&utils.RSRField{Id: utils.TOR}); tor != utils.VOICE {
@@ -559,3 +559,7 @@ func TestParseEventValue(t *testing.T) {
t.Error("Unexpected result parsed", parsed)
}
}
func TestPassesFieldFilter(t *testing.T) {
}

View File

@@ -40,7 +40,7 @@ type CgrCdr map[string]string
func (cgrCdr CgrCdr) getCgrId() string {
setupTime, _ := ParseTimeDetectLayout(cgrCdr[SETUP_TIME])
return Sha1(cgrCdr[ACCID], setupTime.String())
return Sha1(cgrCdr[ACCID], setupTime.UTC().String())
}
func (cgrCdr CgrCdr) getExtraFields() map[string]string {