mirror of
https://github.com/cgrates/cgrates.git
synced 2026-02-11 18:16:24 +05:00
added paginator for GetLcr
This commit is contained in:
@@ -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
|
||||
}
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user