StatEvent.Fields -> StatEvent.Event

This commit is contained in:
DanB
2017-10-22 17:44:33 +02:00
parent c135290fc3
commit 19a811fc5f
6 changed files with 76 additions and 75 deletions

View File

@@ -45,7 +45,7 @@ var evs = []*engine.StatEvent{
&engine.StatEvent{
Tenant: "cgrates.org",
ID: "event1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1001",
utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: time.Duration(135 * time.Second),
@@ -53,14 +53,14 @@ var evs = []*engine.StatEvent{
&engine.StatEvent{
Tenant: "cgrates.org",
ID: "event2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1002",
utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: time.Duration(45 * time.Second)}},
&engine.StatEvent{
Tenant: "cgrates.org",
ID: "event3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1002",
utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: 0}},
@@ -173,7 +173,7 @@ func testV1STSProcessEvent(t *testing.T) {
ev1 := engine.StatEvent{
Tenant: "cgrates.org",
ID: "event1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1001",
utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: time.Duration(135 * time.Second),
@@ -202,7 +202,7 @@ func testV1STSProcessEvent(t *testing.T) {
ev2 := engine.StatEvent{
Tenant: "cgrates.org",
ID: "event2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1002",
utils.ANSWER_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: time.Duration(45 * time.Second)}}
@@ -214,7 +214,7 @@ func testV1STSProcessEvent(t *testing.T) {
ev3 := &engine.StatEvent{
Tenant: "cgrates.org",
ID: "event3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.ACCOUNT: "1002",
utils.SETUP_TIME: time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.USAGE: 0}}

View File

@@ -339,7 +339,7 @@ func testV1TSUpdateThresholdProfile(t *testing.T) {
} else if result != utils.OK {
t.Error("Unexpected reply returned", result)
}
time.Sleep(time.Duration(10 * time.Millisecond)) // mongo is async
time.Sleep(time.Duration(100 * time.Millisecond)) // mongo is async
var reply *engine.ThresholdProfile
if err := tSv1Rpc.Call("ApierV1.GetThresholdProfile",
&utils.TenantID{Tenant: "cgrates.org", ID: "TEST_PROFILE1"}, &reply); err != nil {
@@ -359,7 +359,8 @@ func testV1TSRemoveThresholdProfile(t *testing.T) {
}
var sqp *engine.ThresholdProfile
if err := tSv1Rpc.Call("ApierV1.GetThresholdProfile",
&utils.TenantID{Tenant: "cgrates.org", ID: "TEST_PROFILE1"}, &sqp); err == nil || err.Error() != utils.ErrNotFound.Error() {
&utils.TenantID{Tenant: "cgrates.org", ID: "TEST_PROFILE1"}, &sqp); err == nil ||
err.Error() != utils.ErrNotFound.Error() {
t.Error(err)
}
}

View File

@@ -51,7 +51,7 @@ func (sqp *StatQueueProfile) TenantID() string {
type StatEvent struct {
Tenant string
ID string
Fields map[string]interface{}
Event map[string]interface{}
}
// TenantID returns the unique identifier based on Tenant and ID
@@ -61,7 +61,7 @@ func (se StatEvent) TenantID() string {
// AnswerTime returns the AnswerTime of StatEvent
func (se StatEvent) AnswerTime(timezone string) (at time.Time, err error) {
atIf, has := se.Fields[utils.ANSWER_TIME]
atIf, has := se.Event[utils.ANSWER_TIME]
if !has {
return at, utils.ErrNotFound
}
@@ -77,7 +77,7 @@ func (se StatEvent) AnswerTime(timezone string) (at time.Time, err error) {
// Usage returns the Usage of StatEvent
func (se StatEvent) Usage() (at time.Duration, err error) {
usIf, has := se.Fields[utils.USAGE]
usIf, has := se.Event[utils.USAGE]
if !has {
return at, utils.ErrNotFound
}
@@ -96,7 +96,7 @@ func (se StatEvent) Usage() (at time.Duration, err error) {
// Cost returns the Cost of StatEvent
func (se StatEvent) Cost() (cs float64, err error) {
csIf, has := se.Fields[utils.COST]
csIf, has := se.Event[utils.COST]
if !has {
return cs, utils.ErrNotFound
}
@@ -112,7 +112,7 @@ func (se StatEvent) Cost() (cs float64, err error) {
// Pdd returns the Pdd of StatEvent
func (se StatEvent) Pdd() (pdd time.Duration, err error) {
pddIf, has := se.Fields[utils.PDD]
pddIf, has := se.Event[utils.PDD]
if !has {
return pdd, utils.ErrNotFound
}
@@ -131,7 +131,7 @@ func (se StatEvent) Pdd() (pdd time.Duration, err error) {
// Destination returns the Destination of StatEvent
func (se StatEvent) Destination() (ddc string, err error) {
ddcIf, has := se.Fields[utils.DESTINATION]
ddcIf, has := se.Event[utils.DESTINATION]
if !has {
return ddc, utils.ErrNotFound
}

View File

@@ -196,7 +196,7 @@ func TestStatAddStatEvent(t *testing.T) {
} else if asrMetric.Answered != 1 || asrMetric.Count != 2 {
t.Errorf("ASR: %v", asrMetric)
}
ev1.Fields = map[string]interface{}{
ev1.Event = map[string]interface{}{
utils.ANSWER_TIME: time.Now()}
sq.addStatEvent(ev1)
if asr := asrMetric.GetFloat64Value(); asr != 66.66667 {

View File

@@ -26,7 +26,7 @@ import (
func TestASRGetStringValue(t *testing.T) {
asr, _ := NewASR(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
if strVal := asr.GetStringValue(""); strVal != utils.NOT_AVAILABLE {
t.Errorf("wrong asr value: %s", strVal)
@@ -50,10 +50,10 @@ func TestASRGetStringValue(t *testing.T) {
t.Errorf("wrong asr value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
asr.AddEvent(ev4)
asr.AddEvent(ev5)
@@ -75,7 +75,7 @@ func TestASRGetStringValue(t *testing.T) {
func TestASRGetValue(t *testing.T) {
asr, _ := NewASR(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
asr.AddEvent(ev)
if v := asr.GetValue(); v != -1.0 {
@@ -93,10 +93,10 @@ func TestASRGetValue(t *testing.T) {
t.Errorf("wrong asr value: %f", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC)}}
asr.AddEvent(ev4)
asr.AddEvent(ev5)
@@ -121,7 +121,7 @@ func TestASRGetValue(t *testing.T) {
func TestACDGetStringValue(t *testing.T) {
acd, _ := NewACD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.USAGE: time.Duration(10 * time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
}}
@@ -147,13 +147,13 @@ func TestACDGetStringValue(t *testing.T) {
t.Errorf("wrong acd value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -181,7 +181,7 @@ func TestACDGetStringValue(t *testing.T) {
func TestACDGetFloat64Value(t *testing.T) {
acd, _ := NewACD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second)}}
acd.AddEvent(ev)
@@ -194,13 +194,13 @@ func TestACDGetFloat64Value(t *testing.T) {
t.Errorf("wrong acd value: %v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -234,7 +234,7 @@ func TestACDGetFloat64Value(t *testing.T) {
func TestACDGetValue(t *testing.T) {
acd, _ := NewACD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second)}}
acd.AddEvent(ev)
@@ -242,7 +242,7 @@ func TestACDGetValue(t *testing.T) {
t.Errorf("wrong acd value: %+v", v)
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(8 * time.Second)}}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3"}
@@ -260,13 +260,13 @@ func TestACDGetValue(t *testing.T) {
t.Errorf("wrong acd value: %+v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(4*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -290,7 +290,7 @@ func TestACDGetValue(t *testing.T) {
func TestTCDGetStringValue(t *testing.T) {
tcd, _ := NewTCD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(10 * time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
}}
@@ -302,7 +302,7 @@ func TestTCDGetStringValue(t *testing.T) {
t.Errorf("wrong tcd value: %s", strVal)
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(10 * time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
}}
@@ -321,13 +321,13 @@ func TestTCDGetStringValue(t *testing.T) {
t.Errorf("wrong tcd value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -351,7 +351,7 @@ func TestTCDGetStringValue(t *testing.T) {
func TestTCDGetFloat64Value(t *testing.T) {
tcd, _ := NewTCD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second)}}
tcd.AddEvent(ev)
@@ -364,13 +364,13 @@ func TestTCDGetFloat64Value(t *testing.T) {
t.Errorf("wrong tcd value: %f", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -404,7 +404,7 @@ func TestTCDGetFloat64Value(t *testing.T) {
func TestTCDGetValue(t *testing.T) {
tcd, _ := NewTCD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second)}}
tcd.AddEvent(ev)
@@ -412,7 +412,7 @@ func TestTCDGetValue(t *testing.T) {
t.Errorf("wrong tcd value: %+v", v)
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(5 * time.Second)}}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3"}
@@ -430,13 +430,13 @@ func TestTCDGetValue(t *testing.T) {
t.Errorf("wrong tcd value: %+v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -460,7 +460,7 @@ func TestTCDGetValue(t *testing.T) {
func TestACCGetStringValue(t *testing.T) {
acc, _ := NewACC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 12.3}}
if strVal := acc.GetStringValue(""); strVal != utils.NOT_AVAILABLE {
@@ -472,7 +472,7 @@ func TestACCGetStringValue(t *testing.T) {
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2"}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 12.3}}
acc.AddEvent(ev2)
@@ -485,11 +485,11 @@ func TestACCGetStringValue(t *testing.T) {
t.Errorf("wrong acc value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 5.6}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 1.2}}
acc.AddEvent(ev4)
@@ -512,7 +512,7 @@ func TestACCGetStringValue(t *testing.T) {
func TestACCGetValue(t *testing.T) {
acc, _ := NewACC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "12.3"}}
if strVal := acc.GetValue(); strVal != -1.0 {
@@ -534,11 +534,11 @@ func TestACCGetValue(t *testing.T) {
t.Errorf("wrong acc value: %v", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "5.6"}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "1.2"}}
acc.AddEvent(ev4)
@@ -561,7 +561,7 @@ func TestACCGetValue(t *testing.T) {
func TestTCCGetStringValue(t *testing.T) {
tcc, _ := NewTCC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 12.3}}
if strVal := tcc.GetStringValue(""); strVal != utils.NOT_AVAILABLE {
@@ -573,7 +573,7 @@ func TestTCCGetStringValue(t *testing.T) {
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2"}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 5.7}}
tcc.AddEvent(ev2)
@@ -586,11 +586,11 @@ func TestTCCGetStringValue(t *testing.T) {
t.Errorf("wrong tcc value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 5.6}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 1.2}}
tcc.AddEvent(ev4)
@@ -613,7 +613,7 @@ func TestTCCGetStringValue(t *testing.T) {
func TestTCCGetValue(t *testing.T) {
tcc, _ := NewTCC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "12.3"}}
if strVal := tcc.GetValue(); strVal != -1.0 {
@@ -625,7 +625,7 @@ func TestTCCGetValue(t *testing.T) {
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2"}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": 1.2}}
tcc.AddEvent(ev2)
@@ -638,11 +638,11 @@ func TestTCCGetValue(t *testing.T) {
t.Errorf("wrong tcc value: %v", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "5.6"}}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Cost": "1.2"}}
tcc.AddEvent(ev4)
@@ -665,7 +665,7 @@ func TestTCCGetValue(t *testing.T) {
func TestPDDGetStringValue(t *testing.T) {
pdd, _ := NewPDD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.USAGE: time.Duration(10 * time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.PDD: time.Duration(5 * time.Second),
@@ -693,14 +693,14 @@ func TestPDDGetStringValue(t *testing.T) {
t.Errorf("wrong pdd value: %s", strVal)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.PDD: time.Duration(10 * time.Second),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
utils.PDD: time.Duration(10 * time.Second),
},
}
@@ -727,7 +727,7 @@ func TestPDDGetStringValue(t *testing.T) {
func TestPDDGetFloat64Value(t *testing.T) {
pdd, _ := NewPDD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second),
utils.PDD: time.Duration(5 * time.Second)}}
@@ -741,14 +741,14 @@ func TestPDDGetFloat64Value(t *testing.T) {
t.Errorf("wrong pdd value: %v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
utils.PDD: time.Duration(10 * time.Second),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -782,7 +782,7 @@ func TestPDDGetFloat64Value(t *testing.T) {
func TestPDDGetValue(t *testing.T) {
pdd, _ := NewPDD(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second),
utils.PDD: time.Duration(9 * time.Second)}}
@@ -791,7 +791,7 @@ func TestPDDGetValue(t *testing.T) {
t.Errorf("wrong pdd value: %+v", v)
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(8 * time.Second),
utils.PDD: time.Duration(10 * time.Second)}}
@@ -810,14 +810,14 @@ func TestPDDGetValue(t *testing.T) {
t.Errorf("wrong pdd value: %+v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.PDD: time.Duration(8 * time.Second),
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(4*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
},
@@ -841,7 +841,7 @@ func TestPDDGetValue(t *testing.T) {
func TestDDCGetStringValue(t *testing.T) {
ddc, _ := NewDCC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.DESTINATION: "1002"}}
if strVal := ddc.GetStringValue(""); strVal != utils.NOT_AVAILABLE {
@@ -853,12 +853,12 @@ func TestDDCGetStringValue(t *testing.T) {
t.Errorf("wrong ddc value: %s", strVal)
}
ev2 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_2",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.DESTINATION: "1002"}}
ev3 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_3",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
utils.DESTINATION: "1001"}}
ddc.AddEvent(ev2)
@@ -883,7 +883,7 @@ func TestDDCGetStringValue(t *testing.T) {
func TestDDCGetFloat64Value(t *testing.T) {
ddc, _ := NewDCC(2)
ev := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_1",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"AnswerTime": time.Date(2014, 7, 14, 14, 25, 0, 0, time.UTC),
"Usage": time.Duration(10 * time.Second),
utils.PDD: time.Duration(5 * time.Second),
@@ -898,7 +898,7 @@ func TestDDCGetFloat64Value(t *testing.T) {
t.Errorf("wrong ddc value: %v", v)
}
ev4 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_4",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1 * time.Minute),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
utils.PDD: time.Duration(10 * time.Second),
@@ -906,7 +906,7 @@ func TestDDCGetFloat64Value(t *testing.T) {
},
}
ev5 := &StatEvent{Tenant: "cgrates.org", ID: "EVENT_5",
Fields: map[string]interface{}{
Event: map[string]interface{}{
"Usage": time.Duration(1*time.Minute + 30*time.Second),
"AnswerTime": time.Date(2015, 7, 14, 14, 25, 0, 0, time.UTC),
utils.DESTINATION: "1003",

View File

@@ -137,7 +137,7 @@ func (sS *StatService) StoreStatQueue(sq *StatQueue) (err error) {
// matchingStatQueuesForEvent returns ordered list of matching resources which are active by the time of the call
func (sS *StatService) matchingStatQueuesForEvent(ev *StatEvent) (sqs StatQueues, err error) {
matchingSQs := make(map[string]*StatQueue)
sqIDs, err := matchingItemIDsForEvent(ev.Fields, sS.dm, utils.StatQueuesStringIndex+ev.Tenant)
sqIDs, err := matchingItemIDsForEvent(ev.Event, sS.dm, utils.StatQueuesStringIndex+ev.Tenant)
if err != nil {
return nil, err
}
@@ -158,7 +158,7 @@ func (sS *StatService) matchingStatQueuesForEvent(ev *StatEvent) (sqs StatQueues
}
passAllFilters := true
for _, fltr := range sqPrfl.Filters {
if pass, err := fltr.Pass(ev.Fields, "", sS); err != nil {
if pass, err := fltr.Pass(ev.Event, "", sS); err != nil {
return nil, err
} else if !pass {
passAllFilters = false