From 365032c4d9d1da60828d00045368b71ae4357720 Mon Sep 17 00:00:00 2001 From: TeoV Date: Mon, 15 Apr 2019 17:35:53 +0300 Subject: [PATCH] Remove Paginator from GetSuppliers --- engine/suppliers.go | 11 ----- engine/suppliers_test.go | 86 ---------------------------------------- sessions/sessions.go | 1 - 3 files changed, 98 deletions(-) diff --git a/engine/suppliers.go b/engine/suppliers.go index 7462e652e..c348a90b9 100644 --- a/engine/suppliers.go +++ b/engine/suppliers.go @@ -416,16 +416,6 @@ func (spS *SupplierService) sortedSuppliersForEvent(args *ArgsGetSuppliers) (sor if err != nil { return nil, err } - if args.Paginator.Offset != nil { - if *args.Paginator.Offset <= len(sortedSuppliers.SortedSuppliers) { - sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[*args.Paginator.Offset:] - } - } - if args.Paginator.Limit != nil { - if *args.Paginator.Limit <= len(sortedSuppliers.SortedSuppliers) { - sortedSuppliers.SortedSuppliers = sortedSuppliers.SortedSuppliers[:*args.Paginator.Limit] - } - } return sortedSuppliers, nil } @@ -433,7 +423,6 @@ type ArgsGetSuppliers struct { IgnoreErrors bool MaxCost string // toDo: try with interface{} here utils.CGREvent - utils.Paginator *utils.ArgDispatcher } diff --git a/engine/suppliers_test.go b/engine/suppliers_test.go index 72e505a19..b023055ae 100644 --- a/engine/suppliers_test.go +++ b/engine/suppliers_test.go @@ -492,92 +492,6 @@ func TestSuppliersSortedForEvent(t *testing.T) { } } -func TestSuppliersSortedForEventWithLimit(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", - Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{ - { - SupplierID: "supplier1", - SortingData: map[string]interface{}{ - "Weight": 30.0, - }, - SupplierParameters: "param1", - }, - { - SupplierID: "supplier2", - SortingData: map[string]interface{}{ - "Weight": 20.0, - }, - SupplierParameters: "param2", - }, - }, - } - argsGetSuppliers[1].Paginator = utils.Paginator{ - Limit: utils.IntPointer(2), - } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) - if err != nil { - t.Errorf("Error: %+v", err) - } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v, received: %+v", eFirstSupplierProfile, sprf) - } -} - -func TestSuppliersSortedForEventWithOffset(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", - Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{ - { - SupplierID: "supplier3", - SortingData: map[string]interface{}{ - "Weight": 10.0, - }, - SupplierParameters: "param3", - }, - }, - } - argsGetSuppliers[1].Paginator = utils.Paginator{ - Offset: utils.IntPointer(2), - } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) - if err != nil { - t.Errorf("Error: %+v", err) - } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf)) - } -} - -func TestSuppliersSortedForEventWithLimitAndOffset(t *testing.T) { - eFirstSupplierProfile := &SortedSuppliers{ - ProfileID: "SupplierProfile2", - Sorting: utils.MetaWeight, - SortedSuppliers: []*SortedSupplier{ - { - SupplierID: "supplier2", - SortingData: map[string]interface{}{ - "Weight": 20.0, - }, - SupplierParameters: "param2", - }, - }, - } - argsGetSuppliers[1].Paginator = utils.Paginator{ - Limit: utils.IntPointer(1), - Offset: utils.IntPointer(1), - } - sprf, err := splService.sortedSuppliersForEvent(argsGetSuppliers[1]) - if err != nil { - t.Errorf("Error: %+v", err) - } - if !reflect.DeepEqual(eFirstSupplierProfile, sprf) { - t.Errorf("Expecting: %+v,received: %+v", utils.ToJSON(eFirstSupplierProfile), utils.ToJSON(sprf)) - } -} - func TestSuppliersAsOptsGetSuppliers(t *testing.T) { s := &ArgsGetSuppliers{ IgnoreErrors: true, diff --git a/sessions/sessions.go b/sessions/sessions.go index d941a331f..986c6610e 100644 --- a/sessions/sessions.go +++ b/sessions/sessions.go @@ -1720,7 +1720,6 @@ func (sS *SessionS) BiRPCv1AuthorizeEvent(clnt rpcclient.RpcClientConnection, IgnoreErrors: args.SuppliersIgnoreErrors, MaxCost: args.SuppliersMaxCost, CGREvent: *cgrEv, - Paginator: args.Paginator, ArgDispatcher: args.ArgDispatcher, } if err = sS.splS.Call(utils.SupplierSv1GetSuppliers,