[WIP] #19 Fixed error
This commit is contained in:
parent
b2aacf6686
commit
f45e48dc85
|
@ -13,7 +13,7 @@ class ChanceRepository(RedisRepository):
|
|||
:param chat_id: ID of chat
|
||||
:return: Current chance
|
||||
"""
|
||||
key = self.source(chat_id)
|
||||
key = self.source_name.format(chat_id)
|
||||
chance = self.redis.instance().get(key)
|
||||
|
||||
return self.to_int(chance, self.default_chance)
|
||||
|
@ -25,7 +25,7 @@ class ChanceRepository(RedisRepository):
|
|||
:param new_chance: Chance to set
|
||||
:return: Old chance
|
||||
"""
|
||||
key = self.source(chat_id)
|
||||
key = self.source_name.format(chat_id)
|
||||
old_chance = self.redis.instance().getset(key, new_chance)
|
||||
|
||||
return self.to_int(old_chance, self.default_chance)
|
||||
|
|
|
@ -17,7 +17,7 @@ class MediaRepository(RedisRepository):
|
|||
"""
|
||||
self.redis \
|
||||
.instance() \
|
||||
.zremrangebyscore(self.source(chat_id), 0, dt.timestamp())
|
||||
.zremrangebyscore(self.source_name.format(chat_id), 0, dt.timestamp())
|
||||
|
||||
def is_exists(self, chat_id, media_list):
|
||||
"""
|
||||
|
@ -28,7 +28,7 @@ class MediaRepository(RedisRepository):
|
|||
"""
|
||||
delete_at = (datetime.now() + self.lifetime).timestamp()
|
||||
pipe = self.redis.instance().pipeline()
|
||||
key = self.source(chat_id)
|
||||
key = self.source_name.format(chat_id)
|
||||
|
||||
for media in media_list:
|
||||
pipe.zadd(key, media, delete_at)
|
||||
|
|
|
@ -7,9 +7,6 @@ class RedisRepository(BaseRepository):
|
|||
self.redis = redis
|
||||
self.source_name = source_name
|
||||
|
||||
def source(self, *args):
|
||||
return self.source_name.format(args)
|
||||
|
||||
def to_int(self, byte, default):
|
||||
if byte is None:
|
||||
return default
|
||||
|
|
Loading…
Reference in New Issue