diff --git a/engine/calldesc.go b/engine/calldesc.go index 6fcd0f793..8b38da817 100644 --- a/engine/calldesc.go +++ b/engine/calldesc.go @@ -779,7 +779,7 @@ func (cd *CallDescriptor) GetLCRFromStorage() (*LCR, error) { return nil, utils.ErrNotFound } -func (cd *CallDescriptor) GetLCR(stats StatsInterface) (*LCRCost, error) { +func (cd *CallDescriptor) GetLCR(stats StatsInterface, p *utils.Paginator) (*LCRCost, error) { cd.account = nil // make sure it's not cached lcr, err := cd.GetLCRFromStorage() if err != nil { @@ -1111,5 +1111,13 @@ func (cd *CallDescriptor) GetLCR(stats StatsInterface) (*LCRCost, error) { // sort according to strategy lcrCost.Sort() } + if p != nil { + if p.Offset != nil && *p.Offset > 0 && *p.Offset < len(lcrCost.SupplierCosts)-1 { + lcrCost.SupplierCosts = lcrCost.SupplierCosts[*p.Offset:] + } + if p.Limit != nil && *p.Limit > 0 && *p.Limit < len(lcrCost.SupplierCosts)-1 { + lcrCost.SupplierCosts = lcrCost.SupplierCosts[:*p.Limit] + } + } return lcrCost, nil } diff --git a/engine/lcr_test.go b/engine/lcr_test.go index 93fb2c6d4..1bd083d87 100644 --- a/engine/lcr_test.go +++ b/engine/lcr_test.go @@ -204,7 +204,7 @@ func TestLcrGet(t *testing.T) { Account: "rif", Subject: "rif", } - lcr, err := cd.GetLCR(nil) + lcr, err := cd.GetLCR(nil, nil) //jsn, _ := json.Marshal(lcr) //log.Print("LCR: ", string(jsn)) if err != nil || lcr == nil { diff --git a/engine/responder.go b/engine/responder.go index 88a4b1688..e0471e835 100644 --- a/engine/responder.go +++ b/engine/responder.go @@ -335,7 +335,7 @@ func (rs *Responder) GetLCR(cd *CallDescriptor, reply *LCRCost) error { udRcv := upData.(*CallDescriptor) *cd = *udRcv } - lcrCost, err := cd.GetLCR(rs.Stats) + lcrCost, err := cd.GetLCR(rs.Stats, nil) if err != nil { return err }