Added delta to the Json Representation

This commit is contained in:
Loweel 2019-11-28 14:52:44 +01:00
parent 560c2c5c7a
commit 6b5339562b

15
file.go
View file

@ -19,14 +19,17 @@ type dumpStruct struct {
type GOOD struct {
Token string `json:"Token"`
LastSeen string `json:"LastSeen"`
Delta string `json:"Age"`
}
type BAD struct {
Token string `json:"Token"`
LastSeen string `json:"LastSeen"`
Delta string `json:"Age"`
}
type MEH struct {
Token string `json:"Token"`
LastSeen string `json:"LastSeen"`
Delta string `json:"Age"`
}
type STATS struct {
Decision string `json:"Decision"`
@ -67,24 +70,30 @@ func saveBayesToFile() {
Classifier.BAD.Range(func(key interface{}, value interface{}) bool {
var t BAD
v := value.(int64)
t.Token = key.(string)
t.LastSeen = time.Unix(0, value.(int64)).String()
t.LastSeen = time.Unix(0, v).String()
t.Delta = time.Since(time.Unix(0, v)).String()
DumpJson.BAD = append(DumpJson.BAD, t)
return true
})
Classifier.GOOD.Range(func(key interface{}, value interface{}) bool {
var t GOOD
v := value.(int64)
t.Token = key.(string)
t.LastSeen = time.Unix(0, value.(int64)).String()
t.LastSeen = time.Unix(0, v).String()
t.Delta = time.Since(time.Unix(0, v)).String()
DumpJson.GOOD = append(DumpJson.GOOD, t)
return true
})
Classifier.MEH.Range(func(key interface{}, value interface{}) bool {
var t MEH
v := value.(int64)
t.Token = key.(string)
t.LastSeen = time.Unix(0, value.(int64)).String()
t.LastSeen = time.Unix(0, v).String()
t.Delta = time.Since(time.Unix(0, v)).String()
DumpJson.MEH = append(DumpJson.MEH, t)
return true
})