mirror of
https://github.com/valitydev/redash.git
synced 2024-11-07 09:28:51 +00:00
Fix: old task trackers were not really removed
This commit is contained in:
parent
1a1160eb76
commit
b2e2277d0b
@ -123,7 +123,7 @@ class QueryTaskTracker(object):
|
||||
|
||||
remove_count = count - keep_count
|
||||
keys = redis_connection.zrange(list_name, 0, remove_count - 1)
|
||||
redis_connection.delete(keys)
|
||||
redis_connection.delete(*keys)
|
||||
redis_connection.zremrangebyrank(list_name, 0, remove_count - 1)
|
||||
|
||||
return remove_count
|
||||
|
@ -7,8 +7,12 @@ class TestPrune(TestCase):
|
||||
def setUp(self):
|
||||
self.list = "test_list"
|
||||
redis_connection.delete(self.list)
|
||||
self.keys = []
|
||||
for score in range(0, 100):
|
||||
redis_connection.zadd(self.list, score, 'k:{}'.format(score))
|
||||
key = 'k:{}'.format(score)
|
||||
self.keys.append(key)
|
||||
redis_connection.zadd(self.list, score, key)
|
||||
redis_connection.set(key, 1)
|
||||
|
||||
def test_does_nothing_when_below_threshold(self):
|
||||
remove_count = QueryTaskTracker.prune(self.list, 100)
|
||||
@ -22,3 +26,6 @@ class TestPrune(TestCase):
|
||||
|
||||
self.assertEqual(redis_connection.zscore(self.list, 'k:99'), 99.0)
|
||||
self.assertIsNone(redis_connection.zscore(self.list, 'k:1'))
|
||||
|
||||
for k in self.keys[0:50]:
|
||||
self.assertFalse(redis_connection.exists(k))
|
||||
|
Loading…
Reference in New Issue
Block a user