better getlcr paginator

This commit is contained in:
Radu Ioan Fericean
2015-08-04 19:39:38 +03:00
parent c80a6d7857
commit a17e8445cb

View File

@@ -1112,10 +1112,10 @@ func (cd *CallDescriptor) GetLCR(stats StatsInterface, p *utils.Paginator) (*LCR
lcrCost.Sort()
}
if p != nil {
if p.Offset != nil && *p.Offset > 0 && *p.Offset < len(lcrCost.SupplierCosts)-1 {
if p.Offset != nil && *p.Offset > 0 && *p.Offset < len(lcrCost.SupplierCosts) {
lcrCost.SupplierCosts = lcrCost.SupplierCosts[*p.Offset:]
}
if p.Limit != nil && *p.Limit > 0 && *p.Limit < len(lcrCost.SupplierCosts)-1 {
if p.Limit != nil && *p.Limit > 0 && *p.Limit < len(lcrCost.SupplierCosts) {
lcrCost.SupplierCosts = lcrCost.SupplierCosts[:*p.Limit]
}
}