mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-20 22:58:44 +05:00
Formated code
This commit is contained in:
@@ -127,6 +127,7 @@ func testTPResGetTPResourceBeforeSet(t *testing.T) {
|
||||
|
||||
func testTPResSetTPResource(t *testing.T) {
|
||||
tpRes = &utils.TPResource{
|
||||
Tenant:"Tester",
|
||||
TPid: "TPR1",
|
||||
ID: "Res",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
|
||||
@@ -42,8 +42,8 @@ func InitDataDb(cfg *config.CGRConfig) error {
|
||||
return err
|
||||
}
|
||||
dataDB.LoadDataDBCache(nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil, nil)
|
||||
// Write version before starting
|
||||
if err := CheckVersions(dataDB); err != nil {
|
||||
// Write version before starting
|
||||
if err := CheckVersions(dataDB); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
|
||||
@@ -1392,9 +1392,9 @@ func TestLoadReverseAliases(t *testing.T) {
|
||||
func TestLoadResourceProfiles(t *testing.T) {
|
||||
eResProfiles := map[string]*utils.TPResource{
|
||||
"ResGroup21": &utils.TPResource{
|
||||
TPid: testTPID,
|
||||
Tenant:"Tester",
|
||||
ID: "ResGroup21",
|
||||
TPid: testTPID,
|
||||
Tenant: "Tester",
|
||||
ID: "ResGroup21",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{Type: MetaString, FieldName: "HdrAccount", Values: []string{"1001", "1002"}},
|
||||
&utils.TPRequestFilter{Type: MetaStringPrefix, FieldName: "HdrDestination", Values: []string{"10", "20"}},
|
||||
@@ -1409,9 +1409,9 @@ func TestLoadResourceProfiles(t *testing.T) {
|
||||
Limit: "2",
|
||||
},
|
||||
"ResGroup22": &utils.TPResource{
|
||||
TPid: testTPID,
|
||||
Tenant:"Tester",
|
||||
ID: "ResGroup22",
|
||||
TPid: testTPID,
|
||||
Tenant: "Tester",
|
||||
ID: "ResGroup22",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{Type: MetaDestinations, FieldName: "HdrDestination", Values: []string{"DST_FS"}},
|
||||
},
|
||||
@@ -1438,9 +1438,9 @@ func TestLoadResourceProfiles(t *testing.T) {
|
||||
func TestLoadStats(t *testing.T) {
|
||||
eStats := map[string]*utils.TPStats{
|
||||
"Stats1": &utils.TPStats{
|
||||
Tenant:"Tester",
|
||||
TPid: testTPID,
|
||||
ID: "Stats1",
|
||||
Tenant: "Tester",
|
||||
TPid: testTPID,
|
||||
ID: "Stats1",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{Type: MetaString, FieldName: "Account", Values: []string{"1001", "1002"}},
|
||||
},
|
||||
|
||||
@@ -1880,9 +1880,9 @@ func APItoModelResource(rl *utils.TPResource) (mdls TpResources) {
|
||||
}
|
||||
for i, fltr := range rl.Filters {
|
||||
mdl := &TpResource{
|
||||
Tpid: rl.TPid,
|
||||
Tenant: rl.Tenant,
|
||||
Tag: rl.ID,
|
||||
Tpid: rl.TPid,
|
||||
Tenant: rl.Tenant,
|
||||
Tag: rl.ID,
|
||||
}
|
||||
if i == 0 {
|
||||
mdl.UsageTTL = rl.UsageTTL
|
||||
@@ -1963,7 +1963,7 @@ func (tps TpStatsS) AsTPStats() (result []*utils.TPStats) {
|
||||
st, found := mst[tp.Tag]
|
||||
if !found {
|
||||
st = &utils.TPStats{
|
||||
Tenant: tp.Tenant,
|
||||
Tenant: tp.Tenant,
|
||||
TPid: tp.Tpid,
|
||||
ID: tp.Tag,
|
||||
Blocker: tp.Blocker,
|
||||
@@ -2031,9 +2031,9 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) {
|
||||
}
|
||||
for i, fltr := range st.Filters {
|
||||
mdl := &TpStats{
|
||||
Tenant: st.Tenant,
|
||||
Tpid: st.TPid,
|
||||
Tag: st.ID,
|
||||
Tenant: st.Tenant,
|
||||
Tpid: st.TPid,
|
||||
Tag: st.ID,
|
||||
}
|
||||
if i == 0 {
|
||||
mdl.TTL = st.TTL
|
||||
@@ -2077,7 +2077,7 @@ func APItoModelStats(st *utils.TPStats) (mdls TpStatsS) {
|
||||
|
||||
func APItoStats(tpST *utils.TPStats, timezone string) (st *StatQueueProfile, err error) {
|
||||
st = &StatQueueProfile{
|
||||
Tenant: tpST.Tenant,
|
||||
Tenant: tpST.Tenant,
|
||||
ID: tpST.ID,
|
||||
QueueLength: tpST.QueueLength,
|
||||
Weight: tpST.Weight,
|
||||
|
||||
@@ -713,7 +713,7 @@ func TestTpResourcesAsTpResources(t *testing.T) {
|
||||
tps := []*TpResource{
|
||||
&TpResource{
|
||||
Tpid: "TEST_TPID",
|
||||
Tenant: "Tester",
|
||||
Tenant: "Tester",
|
||||
Tag: "ResGroup1",
|
||||
FilterType: MetaStringPrefix,
|
||||
FilterFieldName: "Destination",
|
||||
@@ -727,14 +727,14 @@ func TestTpResourcesAsTpResources(t *testing.T) {
|
||||
&TpResource{
|
||||
Tpid: "TEST_TPID",
|
||||
Tag: "ResGroup1",
|
||||
Tenant: "Tester",
|
||||
Tenant: "Tester",
|
||||
FilterType: MetaStringPrefix,
|
||||
FilterFieldName: "Category",
|
||||
FilterFieldValues: "call;inbound_call",
|
||||
Thresholds: "WARN3"},
|
||||
&TpResource{
|
||||
Tpid: "TEST_TPID",
|
||||
Tenant: "Tester",
|
||||
Tenant: "Tester",
|
||||
Tag: "ResGroup2",
|
||||
FilterType: MetaStringPrefix,
|
||||
FilterFieldName: "Destination",
|
||||
@@ -747,9 +747,9 @@ func TestTpResourcesAsTpResources(t *testing.T) {
|
||||
}
|
||||
eTPs := []*utils.TPResource{
|
||||
&utils.TPResource{
|
||||
TPid: tps[0].Tpid,
|
||||
Tenant: tps[0].Tenant,
|
||||
ID: tps[0].Tag,
|
||||
TPid: tps[0].Tpid,
|
||||
Tenant: tps[0].Tenant,
|
||||
ID: tps[0].Tag,
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{
|
||||
Type: tps[0].FilterType,
|
||||
@@ -772,9 +772,9 @@ func TestTpResourcesAsTpResources(t *testing.T) {
|
||||
Thresholds: []string{"WARN_RES1", "WARN_RES2", "WARN3"},
|
||||
},
|
||||
&utils.TPResource{
|
||||
TPid: tps[2].Tpid,
|
||||
Tenant: tps[2].Tenant,
|
||||
ID: tps[2].Tag,
|
||||
TPid: tps[2].Tpid,
|
||||
Tenant: tps[2].Tenant,
|
||||
ID: tps[2].Tag,
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{
|
||||
Type: tps[2].FilterType,
|
||||
|
||||
@@ -454,7 +454,7 @@ func (t TBLSMCosts) TableName() string {
|
||||
type TpResource struct {
|
||||
ID int64
|
||||
Tpid string
|
||||
Tenant string `index:"0" re:""`
|
||||
Tenant string `index:"0" re:""`
|
||||
Tag string `index:"1" re:""`
|
||||
FilterType string `index:"2" re:"^\*[A-Za-z].*"`
|
||||
FilterFieldName string `index:"3" re:""`
|
||||
@@ -483,7 +483,7 @@ func (t TBLVersion) TableName() string {
|
||||
type TpStats struct {
|
||||
ID int64
|
||||
Tpid string
|
||||
Tenant string `index:"0" re:""`
|
||||
Tenant string `index:"0" re:""`
|
||||
Tag string `index:"1" re:""`
|
||||
FilterType string `index:"2" re:"^\*[A-Za-z].*"`
|
||||
FilterFieldName string `index:"3" re:""`
|
||||
|
||||
@@ -39,7 +39,7 @@ func init() {
|
||||
|
||||
// ResourceProfile represents the user configuration for the resource
|
||||
type ResourceProfile struct {
|
||||
Tenant string
|
||||
Tenant string
|
||||
ID string // identifier of this resource
|
||||
Filters []*RequestFilter // filters for the request
|
||||
ActivationInterval *utils.ActivationInterval // time when this resource becomes active and expires
|
||||
@@ -54,7 +54,7 @@ type ResourceProfile struct {
|
||||
|
||||
// ResourceUsage represents an usage counted
|
||||
type ResourceUsage struct {
|
||||
Tenant string
|
||||
Tenant string
|
||||
ID string // Unique identifier of this ResourceUsage, Eg: FreeSWITCH UUID
|
||||
ExpiryTime time.Time
|
||||
Units float64 // Number of units used
|
||||
@@ -68,7 +68,7 @@ func (ru *ResourceUsage) isActive(atTime time.Time) bool {
|
||||
// Resource represents a resource in the system
|
||||
// not thread safe, needs locking at process level
|
||||
type Resource struct {
|
||||
Tenant string
|
||||
Tenant string
|
||||
ID string
|
||||
Usages map[string]*ResourceUsage
|
||||
TTLIdx []string // holds ordered list of ResourceIDs based on their TTL, empty if feature is disabled
|
||||
|
||||
@@ -587,7 +587,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, Tag: stq.ID}).Delete(TpStats{}).Error; err != nil {
|
||||
tx.Rollback()
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -1540,9 +1540,9 @@ func testStorDBitCRUDTpStats(t *testing.T) {
|
||||
//WRITE
|
||||
eTPs := []*utils.TPStats{
|
||||
&utils.TPStats{
|
||||
TPid: "TEST_TPID",
|
||||
Tenant:"Test",
|
||||
ID: "Stats1",
|
||||
TPid: "TEST_TPID",
|
||||
Tenant: "Test",
|
||||
ID: "Stats1",
|
||||
Filters: []*utils.TPRequestFilter{
|
||||
&utils.TPRequestFilter{
|
||||
Type: "filtertype",
|
||||
|
||||
Reference in New Issue
Block a user