<commit_before>from sqlalchemy.orm.exc import NoResultFound

from flaskiwsapp.users.models.user import User
from flaskiwsapp.snippets.exceptions.userExceptions import UserDoesnotExistsException,\
    UserExistsException
from sqlalchemy.exc import IntegrityError
from flaskiwsapp.snippets.exceptions.baseExceptions import BaseIWSExceptions


def is_an_available_email(email):
    """
    Verify if an email is available.

    :email: a string object
    :returns: True or False

    """
    return True if User.query.filter(User.email == email).count() else False


def get_all_users():
    """
    Get all users info

    :returns: a dict with the operation result

    """
    # filter(User.email.like('%rafa%')).all()
    return User.query.all()


def get_user_by_email(email=None):
    """
    Get user info by email

    :email: a string object
    :returns: a user object
    """
    try:
        user = User.query.filter(User.email == email).one()
    except NoResultFound:
        raise UserDoesnotExistsException(email)
    return user


def get_user_by_id(user_id=None):
    """
    Get user info by id<commit_msg>Adjust UserController<commit_after>from sqlalchemy.orm.exc import NoResultFound

from flaskiwsapp.users.models.user import User
from flaskiwsapp.snippets.exceptions.userExceptions import UserDoesnotExistsException,\
    UserExistsException
from sqlalchemy.exc import IntegrityError
from flaskiwsapp.snippets.exceptions.baseExceptions import BaseIWSExceptions


def is_an_available_email(email):
    """
    Verify if an email is available.

    :email: a string object
    :returns: True or False

    """
    return False if User.query.filter(User.email == email).count() else True


def get_all_users():
    """
    Get all users info

    :returns: a dict with the operation result

    """
    # filter(User.email.like('%rafa%')).all()
    return User.query.all()


def get_user_by_email(email=None):
    """
    Get user info by email

    :email: a string object
    :returns: a user object
    """
    try:
        user = User.query.filter(User.email == email).one()
    except NoResultFound:
        raise UserDoesnotExistsException(email)
    return user


def get_user_by_id(user_id=None):
    """
    Get user info by id
{'fraction_non_alphanumeric': 0.0940550133096717, 'fraction_numerical': 0.0, 'mean_word_length': 3.4742063492063493, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7052007', 'n_tokens_mistral': 705, 'n_tokens_neox': 676, 'n_words': 184}