mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-12 18:46:24 +05:00
Added Tenant field to TPstats
This commit is contained in:
@@ -273,12 +273,13 @@ ResGroup21,*rsr_fields,,HdrSubject(~^1.*1$);HdrDestination(1002),,,,,,,,
|
||||
ResGroup22,*destinations,HdrDestination,DST_FS,2014-07-29T15:00:00Z,3600s,2,premium_call,true,true,10,
|
||||
`
|
||||
stats = `
|
||||
#Id[0],FilterType[1],FilterFieldName[2],FilterFieldValues[3],ActivationInterval[4],QueueLength[5],TTL[6],Metrics[7],Blocker[8],Stored[9],Weight[10],Thresholds[11]
|
||||
Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
|
||||
#Tenant[0],Id[1],FilterType[2],FilterFieldName[3],FilterFieldValues[4],ActivationInterval[5],QueueLength[6],TTL[7],Metrics[8],Blocker[9],Stored[10],Weight[11],Thresholds[12]
|
||||
Tester,Stats1,*string,Account,1001;1002,2014-07-29T15:00:00Z,100,1s,*asr;*acd;*acc,true,true,20,THRESH1;THRESH2
|
||||
`
|
||||
thresholds = `
|
||||
#Id[0],FilterType[1],FilterFieldName[2],FilterFieldValues[3],ActivationInterval[4],ThresholdType[5],ThresholdValue[6],MinItems[7],Recurrent[8],MinSleep[9],Blocker[10],Stored[11],Weight[12],ActionIDs[13]
|
||||
Threshold1,*string,Account,1001;1002,2014-07-29T15:00:00Z,,1.2,10,true,1s,true,true,10,
|
||||
|
||||
`
|
||||
)
|
||||
|
||||
@@ -1435,6 +1436,7 @@ func TestLoadResourceProfiles(t *testing.T) {
|
||||
func TestLoadStats(t *testing.T) {
|
||||
eStats := map[string]*utils.TPStats{
|
||||
"Stats1": &utils.TPStats{
|
||||
Tenant:"Tester",
|
||||
TPid: testTPID,
|
||||
ID: "Stats1",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
|
||||
@@ -1960,6 +1960,7 @@ func (tps TpStatsS) AsTPStats() (result []*utils.TPStats) {
|
||||
st, found := mst[tp.Tag]
|
||||
if !found {
|
||||
st = &utils.TPStats{
|
||||
Tenant: tp.Tenant,
|
||||
TPid: tp.Tpid,
|
||||
ID: tp.Tag,
|
||||
Blocker: tp.Blocker,
|
||||
@@ -2027,6 +2028,7 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) {
|
||||
}
|
||||
for i, fltr := range st.Filters {
|
||||
mdl := &TpStats{
|
||||
Tenant: st.Tenant,
|
||||
Tpid: st.TPid,
|
||||
Tag: st.ID,
|
||||
}
|
||||
@@ -2072,6 +2074,7 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) {
|
||||
|
||||
func APItoStats(tpST *utils.TPStats, timezone string) (st *StatQueueProfile, err error) {
|
||||
st = &StatQueueProfile{
|
||||
Tenant: tpST.Tenant,
|
||||
ID: tpST.ID,
|
||||
QueueLength: tpST.QueueLength,
|
||||
Weight: tpST.Weight,
|
||||
|
||||
@@ -482,18 +482,19 @@ func (t TBLVersion) TableName() string {
|
||||
type TpStats struct {
|
||||
ID int64
|
||||
Tpid string
|
||||
Tag string `index:"0" re:""`
|
||||
FilterType string `index:"1" re:"^\*[A-Za-z].*"`
|
||||
FilterFieldName string `index:"2" re:""`
|
||||
FilterFieldValues string `index:"3" re:""`
|
||||
ActivationInterval string `index:"4" re:""`
|
||||
QueueLength int `index:"5" re:""`
|
||||
TTL string `index:"6" re:""`
|
||||
Metrics string `index:"7" re:""`
|
||||
Blocker bool `index:"8" re:""`
|
||||
Stored bool `index:"9" re:""`
|
||||
Weight float64 `index:"10" re:"\d+\.?\d*"`
|
||||
Thresholds string `index:"11" re:""`
|
||||
Tenant string `index:"0" re:""`
|
||||
Tag string `index:"1" re:""`
|
||||
FilterType string `index:"2" re:"^\*[A-Za-z].*"`
|
||||
FilterFieldName string `index:"3" re:""`
|
||||
FilterFieldValues string `index:"4" re:""`
|
||||
ActivationInterval string `index:"5" re:""`
|
||||
QueueLength int `index:"6" re:""`
|
||||
TTL string `index:"7" re:""`
|
||||
Metrics string `index:"8" re:""`
|
||||
Blocker bool `index:"9" re:""`
|
||||
Stored bool `index:"10" re:""`
|
||||
Weight float64 `index:"11" re:"\d+\.?\d*"`
|
||||
Thresholds string `index:"12" re:""`
|
||||
CreatedAt time.Time
|
||||
}
|
||||
|
||||
|
||||
@@ -588,7 +588,7 @@ func (self *SQLStorage) SetTPStats(sts []*utils.TPStats) error {
|
||||
tx := self.db.Begin()
|
||||
for _, stq := range sts {
|
||||
// Remove previous
|
||||
if err := tx.Where(&TpStats{Tpid: stq.TPid, Tag: stq.ID}).Delete(TpStats{}).Error; err != nil {
|
||||
if err := tx.Where(&TpStats{Tpid: stq.TPid,Tenant: stq.Tenant,Tag: stq.ID}).Delete(TpStats{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1541,6 +1541,7 @@ func testStorDBitCRUDTpStats(t *testing.T) {
|
||||
eTPs := []*utils.TPStats{
|
||||
&utils.TPStats{
|
||||
TPid: "TEST_TPID",
|
||||
Tenant:"Test",
|
||||
ID: "Stats1",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{
|
||||
|
||||
Reference in New Issue
Block a user