From 4442ae3b8558e9c9104a318cf200773913bb2e52 Mon Sep 17 00:00:00 2001 From: Radu Ioan Fericean Date: Mon, 20 Jun 2016 13:53:25 +0300 Subject: [PATCH] fix limit on load history --- engine/storage_mongo_datadb.go | 5 ++++- engine/storage_redis.go | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/engine/storage_mongo_datadb.go b/engine/storage_mongo_datadb.go index 935ec4914..6feb38dfd 100644 --- a/engine/storage_mongo_datadb.go +++ b/engine/storage_mongo_datadb.go @@ -1274,7 +1274,10 @@ func (ms *MongoStorage) GetLoadHistory(limit int, skipCache bool) (loadInsts []* CacheRemKey(utils.LOADINST_KEY) CacheSet(utils.LOADINST_KEY, loadInsts) } - return loadInsts, nil + if len(loadInsts) < limit || limit == -1 { + return loadInsts, nil + } + return loadInsts[:limit], nil } // Adds a single load instance to load history diff --git a/engine/storage_redis.go b/engine/storage_redis.go index ec0d6fd53..df95898da 100644 --- a/engine/storage_redis.go +++ b/engine/storage_redis.go @@ -934,7 +934,10 @@ func (rs *RedisStorage) GetLoadHistory(limit int, skipCache bool) ([]*utils.Load } CacheRemKey(utils.LOADINST_KEY) CacheSet(utils.LOADINST_KEY, loadInsts) - return loadInsts, nil + if len(loadInsts) < limit || limit == -1 { + return loadInsts, nil + } + return loadInsts[:limit], nil } // Adds a single load instance to load history