@classmethod
    def is_last_admin(cls, user, new_role, new_active):
        is_changing_roles = user.role == 'admin' and new_role != 'admin'
        is_changing_active = user.active is True and new_active is None

        if is_changing_roles or is_changing_active:
            admin_count = User.query.filter(User.role == 'admin').count()
            active_count = User.query.filter(User.is_active is True).count()

            if admin_count == 1 or active_count == 1:
                return True

        return False
Query value for the jmespath query and return answer
dataset/ETHPy150Open nickjj/build-a-saas-app-with-flask/catwatch/blueprints/user/models.py/User.is_last_admin--crossover with--dataset/ETHPy150Open scrapy/scrapy/scrapy/loader/processors.py/SelectJmes.__call__