57c81474b47b31b1278cc544d441759c557e94ac,dino/db/redis.py,DatabaseRedis,is_banned_globally,#DatabaseRedis#Any#,450

Before Change


    def is_banned_globally(self, user_id: str) -> (bool, Union[str, None]):
        ban = self.redis.hget(RedisKeys.banned_users(), user_id)
        // TODO: remove ban if passed, like rdbms implementation
        return self._is_banned(ban)

    def is_banned_from_channel(self, channel_id: str, user_id: str) -> (bool, Union[str, None]):
        ban = self.redis.hget(RedisKeys.banned_users_channel(channel_id), user_id)
        return self._is_banned(ban)

After Change



    def is_banned_globally(self, user_id: str) -> (bool, Union[str, None]):
        ban = self.redis.hget(RedisKeys.banned_users(), user_id)
        is_banned, time = self._is_banned(ban)
        if not is_banned:
            return False, None

        now = datetime.utcnow()
        end = datetime.strptime(time, ConfigKeys.DEFAULT_DATE_FORMAT)
        if now > end:
            self.redis.hdel(RedisKeys.banned_users(), user_id)
            return False, None
        return True, time

    def is_banned_from_channel(self, channel_id: str, user_id: str) -> (bool, Union[str, None]):
        ban = self.redis.hget(RedisKeys.banned_users_channel(channel_id), user_id)
        return self._is_banned(ban)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 22

Instances


Project Name: thenetcircle/dino
Commit Name: 57c81474b47b31b1278cc544d441759c557e94ac
Time: 2016-11-17
Author: oscar.eriks@gmail.com
File Name: dino/db/redis.py
Class Name: DatabaseRedis
Method Name: is_banned_globally


Project Name: thenetcircle/dino
Commit Name: 5341a9e5947ef084513d9dc00b76d4a5c95cb65e
Time: 2016-11-24
Author: oscar.eriks@gmail.com
File Name: dino/db/redis.py
Class Name: DatabaseRedis
Method Name: is_banned_from_room


Project Name: thenetcircle/dino
Commit Name: 5341a9e5947ef084513d9dc00b76d4a5c95cb65e
Time: 2016-11-24
Author: oscar.eriks@gmail.com
File Name: dino/db/redis.py
Class Name: DatabaseRedis
Method Name: is_banned_from_channel


Project Name: thenetcircle/dino
Commit Name: 57c81474b47b31b1278cc544d441759c557e94ac
Time: 2016-11-17
Author: oscar.eriks@gmail.com
File Name: dino/db/redis.py
Class Name: DatabaseRedis
Method Name: is_banned_globally