mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Fix routes' profileCount type
This commit is contained in:
committed by
Dan Christian Bogos
parent
485fb736f4
commit
9d62d65200
@@ -196,7 +196,7 @@ func newCGRConfig(config []byte) (cfg *CGRConfig, err error) {
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
IgnoreErrors: []*utils.DynamicBoolOpt{},
|
||||
MaxCost: []*utils.DynamicInterfaceOpt{},
|
||||
ProfileCount: []*utils.DynamicIntOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
Limit: []*utils.DynamicIntPointerOpt{},
|
||||
Offset: []*utils.DynamicIntPointerOpt{},
|
||||
Usage: []*utils.DynamicDecimalBigOpt{},
|
||||
|
||||
@@ -363,7 +363,7 @@ func testCGRConfigReloadSupplierS(t *testing.T) {
|
||||
DefaultRatio: 1,
|
||||
Opts: &RoutesOpts{
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
ProfileCount: []*utils.DynamicIntOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
IgnoreErrors: []*utils.DynamicBoolOpt{},
|
||||
MaxCost: []*utils.DynamicInterfaceOpt{},
|
||||
Limit: []*utils.DynamicIntPointerOpt{},
|
||||
|
||||
@@ -736,7 +736,7 @@ func TestCgrCfgJSONDefaultRouteSCfg(t *testing.T) {
|
||||
DefaultRatio: 1,
|
||||
Opts: &RoutesOpts{
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
ProfileCount: []*utils.DynamicIntOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
IgnoreErrors: []*utils.DynamicBoolOpt{},
|
||||
MaxCost: []*utils.DynamicInterfaceOpt{},
|
||||
Limit: []*utils.DynamicIntPointerOpt{},
|
||||
@@ -1957,7 +1957,7 @@ func TestRouteSConfig(t *testing.T) {
|
||||
NestedFields: false,
|
||||
Opts: &RoutesOpts{
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
ProfileCount: []*utils.DynamicIntOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
IgnoreErrors: []*utils.DynamicBoolOpt{},
|
||||
MaxCost: []*utils.DynamicInterfaceOpt{},
|
||||
Limit: []*utils.DynamicIntPointerOpt{},
|
||||
@@ -4438,7 +4438,7 @@ func TestV1GetConfigRoutes(t *testing.T) {
|
||||
utils.DefaultRatioCfg: 1,
|
||||
utils.OptsCfg: map[string]interface{}{
|
||||
utils.OptsContext: []*utils.DynamicStringOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaIgnoreErrorsCfg: []*utils.DynamicBoolOpt{},
|
||||
utils.MetaMaxCostCfg: []*utils.DynamicInterfaceOpt{},
|
||||
utils.MetaLimitCfg: []*utils.DynamicIntPointerOpt{},
|
||||
|
||||
@@ -25,11 +25,12 @@ import (
|
||||
"github.com/cgrates/cgrates/utils"
|
||||
)
|
||||
|
||||
var RoutesProfileCountDftOpt = utils.IntPointer(1)
|
||||
|
||||
const (
|
||||
RoutesContextDftOpt = "*routes"
|
||||
RoutesIgnoreErrorsDftOpt = false
|
||||
RoutesMaxCostDftOpt = utils.EmptyString
|
||||
RoutesProfileCountDftOpt = 1
|
||||
RoutesUsageDftOpt = time.Minute
|
||||
)
|
||||
|
||||
@@ -39,7 +40,7 @@ type RoutesOpts struct {
|
||||
MaxCost []*utils.DynamicInterfaceOpt
|
||||
Limit []*utils.DynamicIntPointerOpt
|
||||
Offset []*utils.DynamicIntPointerOpt
|
||||
ProfileCount []*utils.DynamicIntOpt
|
||||
ProfileCount []*utils.DynamicIntPointerOpt
|
||||
Usage []*utils.DynamicDecimalBigOpt
|
||||
}
|
||||
|
||||
@@ -89,7 +90,7 @@ func (rtsOpts *RoutesOpts) loadFromJSONCfg(jsnCfg *RoutesOptsJson) (err error) {
|
||||
rtsOpts.Offset = append(rtsOpts.Offset, utils.IntToIntPointerDynamicOpts(jsnCfg.Offset)...)
|
||||
}
|
||||
if jsnCfg.ProfileCount != nil {
|
||||
rtsOpts.ProfileCount = append(rtsOpts.ProfileCount, jsnCfg.ProfileCount...)
|
||||
rtsOpts.ProfileCount = append(rtsOpts.ProfileCount, utils.IntToIntPointerDynamicOpts(jsnCfg.ProfileCount)...)
|
||||
}
|
||||
if jsnCfg.Usage != nil {
|
||||
var usage []*utils.DynamicDecimalBigOpt
|
||||
@@ -159,9 +160,9 @@ func (rts *RoutesOpts) Clone() (cln *RoutesOpts) {
|
||||
if rts.MaxCost != nil {
|
||||
maxCost = utils.CloneDynamicInterfaceOpt(rts.MaxCost)
|
||||
}
|
||||
var profileCount []*utils.DynamicIntOpt
|
||||
var profileCount []*utils.DynamicIntPointerOpt
|
||||
if rts.ProfileCount != nil {
|
||||
profileCount = utils.CloneDynamicIntOpt(rts.ProfileCount)
|
||||
profileCount = utils.CloneDynamicIntPointerOpt(rts.ProfileCount)
|
||||
}
|
||||
var limit []*utils.DynamicIntPointerOpt
|
||||
if rts.Limit != nil {
|
||||
@@ -318,8 +319,8 @@ func diffRoutesOptsJsonCfg(d *RoutesOptsJson, v1, v2 *RoutesOpts) *RoutesOptsJso
|
||||
if !utils.DynamicBoolOptEqual(v1.IgnoreErrors, v2.IgnoreErrors) {
|
||||
d.IgnoreErrors = v2.IgnoreErrors
|
||||
}
|
||||
if !utils.DynamicIntOptEqual(v1.ProfileCount, v2.ProfileCount) {
|
||||
d.ProfileCount = v2.ProfileCount
|
||||
if !utils.DynamicIntPointerOptEqual(v1.ProfileCount, v2.ProfileCount) {
|
||||
d.ProfileCount = utils.IntPointerToIntDynamicOpts(v2.ProfileCount)
|
||||
}
|
||||
if !utils.DynamicDecimalBigOptEqual(v1.Usage, v2.Usage) {
|
||||
d.Usage = utils.DecimalBigToStringDynamicOpts(v2.Usage)
|
||||
|
||||
@@ -56,7 +56,7 @@ func TestRouteSCfgloadFromJsonCfg(t *testing.T) {
|
||||
NestedFields: true,
|
||||
Opts: &RoutesOpts{
|
||||
Context: []*utils.DynamicStringOpt{},
|
||||
ProfileCount: []*utils.DynamicIntOpt{},
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{},
|
||||
IgnoreErrors: []*utils.DynamicBoolOpt{},
|
||||
MaxCost: []*utils.DynamicInterfaceOpt{},
|
||||
Limit: []*utils.DynamicIntPointerOpt{},
|
||||
@@ -115,7 +115,7 @@ func TestRouteSCfgAsMapInterface(t *testing.T) {
|
||||
utils.OptsContext: []*utils.DynamicStringOpt{},
|
||||
utils.MetaLimitCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaOffsetCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaIgnoreErrorsCfg: []*utils.DynamicBoolOpt{},
|
||||
utils.MetaMaxCostCfg: []*utils.DynamicInterfaceOpt{},
|
||||
utils.MetaUsage: []*utils.DynamicDecimalBigOpt{},
|
||||
@@ -163,7 +163,7 @@ func TestRouteSCfgAsMapInterface1(t *testing.T) {
|
||||
utils.OptsContext: []*utils.DynamicStringOpt{},
|
||||
utils.MetaLimitCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaOffsetCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntOpt{},
|
||||
utils.MetaProfileCountCfg: []*utils.DynamicIntPointerOpt{},
|
||||
utils.MetaIgnoreErrorsCfg: []*utils.DynamicBoolOpt{},
|
||||
utils.MetaMaxCostCfg: []*utils.DynamicInterfaceOpt{},
|
||||
utils.MetaUsage: []*utils.DynamicDecimalBigOpt{},
|
||||
@@ -256,9 +256,9 @@ func TestDiffRouteSJsonCfg(t *testing.T) {
|
||||
Value: utils.IntPointer(2),
|
||||
},
|
||||
},
|
||||
ProfileCount: []*utils.DynamicIntOpt{
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{
|
||||
{
|
||||
Value: 1,
|
||||
Value: utils.IntPointer(1),
|
||||
},
|
||||
},
|
||||
Usage: []*utils.DynamicDecimalBigOpt{
|
||||
@@ -309,9 +309,9 @@ func TestDiffRouteSJsonCfg(t *testing.T) {
|
||||
Value: utils.IntPointer(3),
|
||||
},
|
||||
},
|
||||
ProfileCount: []*utils.DynamicIntOpt{
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{
|
||||
{
|
||||
Value: 2,
|
||||
Value: utils.IntPointer(2),
|
||||
},
|
||||
},
|
||||
Usage: []*utils.DynamicDecimalBigOpt{
|
||||
@@ -430,9 +430,9 @@ func TestRouteSCloneSection(t *testing.T) {
|
||||
Value: utils.IntPointer(1),
|
||||
},
|
||||
},
|
||||
ProfileCount: []*utils.DynamicIntOpt{
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{
|
||||
{
|
||||
Value: 1,
|
||||
Value: utils.IntPointer(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
@@ -475,9 +475,9 @@ func TestRouteSCloneSection(t *testing.T) {
|
||||
Value: utils.IntPointer(1),
|
||||
},
|
||||
},
|
||||
ProfileCount: []*utils.DynamicIntOpt{
|
||||
ProfileCount: []*utils.DynamicIntPointerOpt{
|
||||
{
|
||||
Value: 1,
|
||||
Value: utils.IntPointer(1),
|
||||
},
|
||||
},
|
||||
},
|
||||
|
||||
@@ -386,13 +386,13 @@ func (rpS *RouteS) sortedRoutesForEvent(ctx *context.Context, tnt string, args *
|
||||
return
|
||||
}
|
||||
prfCount := len(rPrfs) // if the option is not present return for all profiles
|
||||
var prfCountOpt int
|
||||
if prfCountOpt, err = GetIntOpts(ctx, tnt, args, rpS.fltrS, rpS.cfg.RouteSCfg().Opts.ProfileCount,
|
||||
config.RoutesProfileCountDftOpt, utils.OptsRoutesProfileCount); err != nil {
|
||||
var prfCountOpt *int
|
||||
if prfCountOpt, err = GetIntPointerOpts(ctx, tnt, args, rpS.fltrS, rpS.cfg.RouteSCfg().Opts.ProfileCount,
|
||||
utils.OptsRoutesProfileCount); err != nil {
|
||||
return
|
||||
}
|
||||
if prfCount > prfCountOpt { // it has the option and is smaller that the current number of profiles
|
||||
prfCount = prfCountOpt
|
||||
if prfCountOpt != nil || prfCount > *prfCountOpt { // it has the option and is smaller that the current number of profiles
|
||||
prfCount = *prfCountOpt
|
||||
}
|
||||
var extraOpts *optsGetRoutes
|
||||
if extraOpts, err = newOptsGetRoutes(ctx, args, rpS.fltrS, rpS.cfg.RouteSCfg().Opts); err != nil { // convert routes arguments into internal options used to limit data
|
||||
|
||||
@@ -94,6 +94,9 @@ var (
|
||||
"PddInterval": "1s",
|
||||
utils.Weight: "20.0",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRoutesProfileCount: 1,
|
||||
},
|
||||
},
|
||||
{ //matching RouteProfile2
|
||||
Tenant: "cgrates.org",
|
||||
@@ -105,6 +108,9 @@ var (
|
||||
"PddInterval": "1s",
|
||||
utils.Weight: "20.0",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRoutesProfileCount: 1,
|
||||
},
|
||||
},
|
||||
{ //matching RouteProfilePrefix
|
||||
Tenant: "cgrates.org",
|
||||
@@ -112,6 +118,9 @@ var (
|
||||
Event: map[string]interface{}{
|
||||
"Route": "RouteProfilePrefix",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRoutesProfileCount: 1,
|
||||
},
|
||||
},
|
||||
{ //matching
|
||||
Tenant: "cgrates.org",
|
||||
@@ -120,6 +129,9 @@ var (
|
||||
"UsageInterval": "1s",
|
||||
"PddInterval": "1s",
|
||||
},
|
||||
APIOpts: map[string]interface{}{
|
||||
utils.OptsRoutesProfileCount: 1,
|
||||
},
|
||||
},
|
||||
}
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user