From b98ccb88d162276f5bdc11978c954a47887c5d66 Mon Sep 17 00:00:00 2001 From: Houkime <> Date: Wed, 14 Dec 2022 17:10:32 +0000 Subject: [PATCH] refactor(tokens-repo): separate getting model dict --- .../repositories/tokens/redis_tokens_repository.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/selfprivacy_api/repositories/tokens/redis_tokens_repository.py b/selfprivacy_api/repositories/tokens/redis_tokens_repository.py index accaacc..af45384 100644 --- a/selfprivacy_api/repositories/tokens/redis_tokens_repository.py +++ b/selfprivacy_api/repositories/tokens/redis_tokens_repository.py @@ -87,12 +87,17 @@ class RedisTokensRepository(AbstractTokensRepository): if d[key] == "None": d[key] = None - def _token_from_hash(self, redis_key: str) -> Token: + def _model_dict_from_hash(self, redis_key: str) -> Optional[dict]: r = self.connection if r.exists(redis_key): token_dict = r.hgetall(redis_key) RedisTokensRepository._prepare_model_dict(token_dict) + return token_dict + return None + def _token_from_hash(self, redis_key: str) -> Optional[Token]: + token_dict = self._model_dict_from_hash(redis_key) + if token_dict is not None: return Token(**token_dict) return None