mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
Make ProfileCount opt from routes a pointer
This commit is contained in:
committed by
Dan Christian Bogos
parent
d4123e9df3
commit
8a4c982af6
@@ -790,7 +790,7 @@ const CGRATES_CFG_JSON = `
|
||||
"default_ratio":1, // default ratio used in case of *load strategy
|
||||
"opts": {
|
||||
"*context": "*routes",
|
||||
"*profileCount": 1,
|
||||
// "*profileCount": 1,
|
||||
"*ignoreErrors": false,
|
||||
"*maxCost": "",
|
||||
// "*limit": 1,
|
||||
|
||||
@@ -28,7 +28,7 @@ type RoutesOpts struct {
|
||||
MaxCost interface{}
|
||||
Limit *int
|
||||
Offset *int
|
||||
ProfileCount int
|
||||
ProfileCount *int
|
||||
}
|
||||
|
||||
// RouteSCfg is the configuration of route service
|
||||
@@ -67,7 +67,7 @@ func (rtsOpts *RoutesOpts) loadFromJSONCfg(jsnCfg *RoutesOptsJson) {
|
||||
rtsOpts.Offset = jsnCfg.Offset
|
||||
}
|
||||
if jsnCfg.ProfileCount != nil {
|
||||
rtsOpts.ProfileCount = *jsnCfg.ProfileCount
|
||||
rtsOpts.ProfileCount = jsnCfg.ProfileCount
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,7 +158,6 @@ func (rts *RouteSCfg) loadFromJSONCfg(jsnCfg *RouteSJsonCfg) (err error) {
|
||||
func (rts *RouteSCfg) AsMapInterface() (initialMP map[string]interface{}) {
|
||||
opts := map[string]interface{}{
|
||||
utils.OptsContext: rts.Opts.Context,
|
||||
utils.MetaProfileCountCfg: rts.Opts.ProfileCount,
|
||||
utils.MetaIgnoreErrorsCfg: rts.Opts.IgnoreErrors,
|
||||
}
|
||||
if rts.Opts.MaxCost != nil {
|
||||
@@ -170,6 +169,9 @@ func (rts *RouteSCfg) AsMapInterface() (initialMP map[string]interface{}) {
|
||||
if rts.Opts.Offset != nil {
|
||||
opts[utils.MetaOffsetCfg] = *rts.Opts.Offset
|
||||
}
|
||||
if rts.Opts.ProfileCount != nil {
|
||||
opts[utils.MetaProfileCountCfg] = rts.Opts.ProfileCount
|
||||
}
|
||||
initialMP = map[string]interface{}{
|
||||
utils.EnabledCfg: rts.Enabled,
|
||||
utils.IndexedSelectsCfg: rts.IndexedSelects,
|
||||
@@ -245,9 +247,11 @@ func (rts *RoutesOpts) Clone() (cln *RoutesOpts) {
|
||||
cln = &RoutesOpts{
|
||||
Context: rts.Context,
|
||||
IgnoreErrors: rts.IgnoreErrors,
|
||||
ProfileCount: rts.ProfileCount,
|
||||
MaxCost: rts.MaxCost,
|
||||
}
|
||||
if rts.ProfileCount != nil {
|
||||
cln.ProfileCount = utils.IntPointer(*rts.ProfileCount)
|
||||
}
|
||||
if rts.Limit != nil {
|
||||
cln.Limit = utils.IntPointer(*rts.Limit)
|
||||
}
|
||||
|
||||
@@ -678,13 +678,13 @@ func (rpS *RouteService) sortedRoutesForEvent(tnt string, args *utils.CGREvent)
|
||||
return
|
||||
}
|
||||
prfCount := len(rPrfs) // if the option is not present return for all profiles
|
||||
var prfCountOpt int
|
||||
if prfCountOpt, err = utils.GetIntOpts(args, rpS.cgrcfg.RouteSCfg().Opts.ProfileCount,
|
||||
var prfCountOpt *int
|
||||
if prfCountOpt, err = utils.GetIntPointerOpts(args, rpS.cgrcfg.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(args, rpS.filterS, rpS.cgrcfg.RouteSCfg().Opts); err != nil { // convert routes arguments into internal options used to limit data
|
||||
|
||||
Reference in New Issue
Block a user