mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-25 00:58:45 +05:00
RawCDR interface now properly returns duration
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user