RawCDR interface now properly returns duration

This commit is contained in:
DanB
2014-04-27 09:19:30 +02:00
parent 330fb7b894
commit f0095dbcb3
8 changed files with 23 additions and 16 deletions

View File

@@ -165,9 +165,8 @@ func (fsCdr FSCdr) GetHangupTime() (t time.Time, err error) {
}
// Extracts duration as considered by the telecom switch
func (fsCdr FSCdr) GetDuration() time.Duration {
dur, _ := utils.ParseDurationWithSecs(fsCdr.vars[FS_DURATION])
return dur
func (fsCdr FSCdr) GetDuration() (time.Duration, error) {
return utils.ParseDurationWithSecs(fsCdr.vars[FS_DURATION])
}
func (fsCdr FSCdr) Store() (result string, err error) {
@@ -192,7 +191,8 @@ func (fsCdr FSCdr) Store() (result string, err error) {
return "", err
}
result += strconv.FormatInt(et.UnixNano(), 10) + "|"
result += strconv.FormatInt(int64(fsCdr.GetDuration().Seconds()), 10) + "|"
dur, _ := fsCdr.GetDuration()
result += strconv.FormatInt(int64(dur.Seconds()), 10) + "|"
return
}

View File

@@ -87,8 +87,9 @@ func TestCDRFields(t *testing.T) {
if answerTime.UTC() != expectedATime {
t.Error("Error parsing answerTime: ", answerTime.UTC())
}
if fsCdr.GetDuration() != 4000000000 {
t.Error("Error parsing duration: ", fsCdr.GetDuration())
dur, _ := fsCdr.GetDuration()
if dur != 4000000000 {
t.Error("Error parsing duration: ", dur)
}
cfg.CDRSExtraFields = []*utils.RSRField{&utils.RSRField{Id: "sip_user_agent"}, &utils.RSRField{Id: "read_codec"}, &utils.RSRField{Id: "write_codec"}}
extraFields := fsCdr.GetExtraFields()