def search(*, include_disabled=True, account_ids=None, account_type_id=None, properties=None, return_query=False):
        """Search for accounts based on the provided filters

        Args:
            include_disabled (`bool`): Include disabled accounts (default: True)
            account_ids: (`list` of `int`): List of account IDs
            account_type_id (`int`): Account Type ID to limit results to
            properties (`dict`): A `dict` containing property name and value pairs. Values can be either a str or a list
            of strings, in which case a boolean OR search is performed on the values
            return_query (`bool`): Returns the query object prior to adding the limit and offset functions. Allows for
            sub-classes to amend the search feature with extra conditions. The calling function must handle pagination
            on its own

        Returns:
            `list` of `Account`, `sqlalchemy.orm.Query`
        """
        qry = db.Account.order_by(desc(Account.enabled), Account.account_type_id, Account.account_name)

        if not include_disabled:
            qry = qry.filter(Account.enabled == 1)

        if account_ids:
            if type(account_ids) not in (list, tuple):
                account_ids = [account_ids]

            qry = qry.filter(Account.account_id.in_(account_ids))

        if account_type_id:
            qry = qry.filter(Account.account_type_id == account_type_id)

        if properties:
            for prop_name, value in properties.items():
                alias = aliased(AccountProperty)
                qry = qry.join(alias, Account.account_id == alias.account_id)
                if type(value) == list:
                    where_clause = []
                    for item in value:
                        where_clause.append(alias.value == item)

                    qry = qry.filter(
                        and_(
                            alias.name == prop_name,
                            or_(*where_clause)
                        ).self_group()
                    )
                else:
                    qry = qry.filter(
                        and_(
                            alias.name == prop_name,
                            alias.value == value
                        ).self_group()
                    )

        if return_query:
            return qry

        total = qry.count()
        return total, list(map(BaseAccount.get_typed_account, qry.all()))
def search ( * , include_disabled = True , account_ids = None , account_type_id = None , properties = None , return_query = False ) : qry = db . Account . order_by ( desc ( Account . enabled ) , Account . account_type_id , Account . account_name ) if not include_disabled : qry = qry . filter ( Account . enabled == 1 ) if account_ids : if type ( account_ids ) not in ( list , tuple ) : account_ids = [ account_ids ] qry = qry . filter ( Account . account_id . in_ ( account_ids ) ) if account_type_id : qry = qry . filter ( Account . account_type_id == account_type_id ) if properties : for prop_name , value in properties . items ( ) : alias = aliased ( AccountProperty ) qry = qry . join ( alias , Account . account_id == alias . account_id ) if type ( value ) == list : where_clause = [ ] for item in value : where_clause . append ( alias . value == item ) qry = qry . filter ( and_ ( alias . name == prop_name , or_ ( * where_clause ) ) . self_group ( ) ) else : qry = qry . filter ( and_ ( alias . name == prop_name , alias . value == value ) . self_group ( ) ) if return_query : return qry total = qry . count ( ) return total , list ( map ( BaseAccount . get_typed_account , qry . all ( ) ) )
Search for accounts based on the provided filters

        Args:
            include_disabled (`bool`): Include disabled accounts (default: True)
            account_ids: (`list` of `int`): List of account IDs
            account_type_id (`int`): Account Type ID to limit results to
            properties (`dict`): A `dict` containing property name and value pairs. Values can be either a str or a list
            of strings, in which case a boolean OR search is performed on the values
            return_query (`bool`): Returns the query object prior to adding the limit and offset functions. Allows for
            sub-classes to amend the search feature with extra conditions. The calling function must handle pagination
            on its own

        Returns:
            `list` of `Account`, `sqlalchemy.orm.Query`