Discarding FS microseconds information, reverting to seconds since MySQL errors in older versions and default FS csv file uses seconds

This commit is contained in:
DanB
2014-04-11 17:12:27 +02:00
parent 5d9e7bae67
commit 4e1776d6fd
3 changed files with 18 additions and 8 deletions

View File

@@ -150,14 +150,24 @@ func (fsev FSEvent) MissingParameter() bool {
strings.TrimSpace(fsev.GetCallDestNr("")) == ""
}
func (fsev FSEvent) GetSetupTime(fieldName string) (t time.Time, err error) {
sTimeStr := utils.FirstNonEmpty(fsev[fieldName], fsev[SETUP_TIME])
fsSTimeStr, hasKey := fsev[SETUP_TIME]
if hasKey {
// Discard the nanoseconds information since MySQL cannot store them in early versions and csv uses default seconds so cgrid will not corelate
fsSTimeStr = fsSTimeStr[:len(fsSTimeStr)-6]
}
sTimeStr := utils.FirstNonEmpty(fsev[fieldName], fsSTimeStr)
if strings.HasPrefix(fieldName, utils.STATIC_VALUE_PREFIX) { // Static value
sTimeStr = fieldName[len(utils.STATIC_VALUE_PREFIX):]
}
return utils.ParseTimeDetectLayout(sTimeStr)
}
func (fsev FSEvent) GetAnswerTime(fieldName string) (t time.Time, err error) {
aTimeStr := utils.FirstNonEmpty(fsev[fieldName], fsev[ANSWER_TIME])
fsATimeStr, hasKey := fsev[ANSWER_TIME]
if hasKey {
// Discard the nanoseconds information since MySQL cannot store them in early versions and csv uses default seconds so cgrid will not corelate
fsATimeStr = fsATimeStr[:len(fsATimeStr)-6]
}
aTimeStr := utils.FirstNonEmpty(fsev[fieldName], fsATimeStr)
if strings.HasPrefix(fieldName, utils.STATIC_VALUE_PREFIX) { // Static value
aTimeStr = fieldName[len(utils.STATIC_VALUE_PREFIX):]
}