mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-15 21:29:52 +05:00
Add FilterS and context parameters for newOptsGetRoutes function and fix the remaining compilation errors
This commit is contained in:
committed by
Dan Christian Bogos
parent
e90e01abd0
commit
a3290f519e
@@ -184,9 +184,14 @@ func (rpS *RouteService) matchingRouteProfilesForEvent(ctx *context.Context, tnt
|
||||
return
|
||||
}
|
||||
|
||||
func newOptsGetRoutes(ev *utils.CGREvent, def *config.RoutesOpts) (opts *optsGetRoutes, err error) {
|
||||
func newOptsGetRoutes(ctx *context.Context, ev *utils.CGREvent, fS *FilterS, def *config.RoutesOpts) (opts *optsGetRoutes, err error) {
|
||||
var ignoreErrors bool
|
||||
if ignoreErrors, err = FilterBoolCfgOpts(ctx, ev.Tenant, ev.AsDataProvider(), fS,
|
||||
def.IgnoreErrors); err != nil {
|
||||
return
|
||||
}
|
||||
opts = &optsGetRoutes{
|
||||
ignoreErrors: utils.OptAsBoolOrDef(ev.APIOpts, utils.OptsRoutesIgnoreErrors, def.IgnoreErrors),
|
||||
ignoreErrors: utils.OptAsBoolOrDef(ev.APIOpts, utils.OptsRoutesIgnoreErrors, ignoreErrors),
|
||||
paginator: &utils.Paginator{
|
||||
Limit: def.Limit,
|
||||
Offset: def.Offset,
|
||||
@@ -267,9 +272,14 @@ func (rpS *RouteService) V1GetRoutes(ctx *context.Context, args *utils.CGREvent,
|
||||
args.APIOpts = make(map[string]interface{})
|
||||
}
|
||||
args.APIOpts[utils.Subsys] = utils.MetaRoutes
|
||||
var context string
|
||||
if context, err = FilterStringCfgOpts(ctx, tnt, args.AsDataProvider(), rpS.filterS,
|
||||
rpS.cfg.RouteSCfg().Opts.Context); err != nil {
|
||||
return
|
||||
}
|
||||
args.APIOpts[utils.OptsContext] = utils.FirstNonEmpty(
|
||||
utils.IfaceAsString(args.APIOpts[utils.OptsContext]),
|
||||
rpS.cfg.RouteSCfg().Opts.Context,
|
||||
context,
|
||||
utils.MetaRoutes)
|
||||
var rplyEv AttrSProcessEventReply
|
||||
if err := rpS.connMgr.Call(ctx, rpS.cfg.RouteSCfg().AttributeSConns,
|
||||
@@ -398,7 +408,7 @@ func (rpS *RouteService) sortedRoutesForEvent(ctx *context.Context, tnt string,
|
||||
}
|
||||
}
|
||||
var extraOpts *optsGetRoutes
|
||||
if extraOpts, err = newOptsGetRoutes(args, rpS.cfg.RouteSCfg().Opts); err != nil { // convert routes arguments into internal options used to limit data
|
||||
if extraOpts, err = newOptsGetRoutes(ctx, args, rpS.filterS, rpS.cfg.RouteSCfg().Opts); err != nil { // convert routes arguments into internal options used to limit data
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
@@ -1482,7 +1482,7 @@ func TestRoutesNewOptsGetRoutes(t *testing.T) {
|
||||
maxCost: 10.0,
|
||||
paginator: &utils.Paginator{},
|
||||
}
|
||||
sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts)
|
||||
sprf, err := newOptsGetRoutes(context.Background(), ev, &FilterS{}, config.CgrConfig().RouteSCfg().Opts)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -1504,7 +1504,7 @@ func TestRoutesNewOptsGetRoutesFromCfg(t *testing.T) {
|
||||
ignoreErrors: true,
|
||||
paginator: &utils.Paginator{},
|
||||
}
|
||||
sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts)
|
||||
sprf, err := newOptsGetRoutes(context.Background(), ev, &FilterS{}, config.CgrConfig().RouteSCfg().Opts)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
@@ -1523,7 +1523,7 @@ func TestRoutesNewOptsGetRoutesIgnoreErrors(t *testing.T) {
|
||||
ignoreErrors: true,
|
||||
paginator: &utils.Paginator{},
|
||||
}
|
||||
sprf, err := newOptsGetRoutes(ev, config.CgrConfig().RouteSCfg().Opts)
|
||||
sprf, err := newOptsGetRoutes(context.Background(), ev, &FilterS{}, config.CgrConfig().RouteSCfg().Opts)
|
||||
if err != nil {
|
||||
t.Errorf("Error: %+v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user