def get_last_user_activity(user_id, guest=False): if guest: last_active = redis.get('guest-activity/%s' % user_id) else: last_active = redis.get('user-activity/%s' % user_id) if last_active is None: return None return datetime.utcfromtimestamp(int(last_active))
def get_last_user_activity(user_id, guest=False): """Returns the last active time from a given user_id :param user_id: The user id for whom you want to know the latest activity :param guest: If the user is a guest (not signed in) """ if guest: last_active = redis.get('guest-activity/%s' % user_id) else: last_active = redis.get('user-activity/%s' % user_id) if last_active is None: return None return datetime.utcfromtimestamp(int(last_active))