<commit_before># stdlib
from datetime import datetime
from typing import Any
from typing import List
from typing import Optional

# third party
from nacl.signing import VerifyKey
from sqlalchemy.engine import Engine
from sqlalchemy.orm import sessionmaker

# relative
from ....common.uid import UID
from ..exceptions import RequestError
from ..node_service.request_receiver.request_receiver_messages import RequestStatus
from ..node_table.request import Request
from .database_manager import DatabaseManager


class RequestManager(DatabaseManager):

    schema = Request

    def __init__(self, database: Engine) -> None:
        super().__init__(schema=RequestManager.schema, db=database)

    def first(self, **kwargs: Any) -> Request:
        result = super().first(**kwargs)
        if not result:
            raise RequestError

        return result

    def create_request(
        self,
        user_id: int,
        user_name: str,
        object_id: str,
        reason: str,
        request_type: str,
        verify_key: Optional[VerifyKey] = None,
        tags: Optional[List[str]] = None,
        object_type: str = "",
    ) -> Request:
        date = datetime.now()

        return self.register(
            id=str(UID().value),
            user_id=user_id,
            user_name=user_name,
            object_id=object_id,
            date=date,
            reason=reason,
            request_type=request_type,
            verify_key=verify_key,
            tags=tags,
            object_type=object_type,
        )

    def status(self, request_id: str) -> RequestStatus:
        _req = self.first(id=request_id)
        if _req.status == "pending":
            return RequestStatus.Pending
        elif _req.status == "accepted":
            return RequestStatus.Accepted
        else:
            return RequestStatus.Rejected

    def set(self, request_id: int, status: RequestStatus) -> None:
        self.modify({"id": request_id}, {"status": status})

    def clear(self) -> None:
        local_session = sessionmaker(bind=self.db)()
        local_session.query(self.schema).delete()
        local_session.commit()
        local_session.close()<commit_msg>ADD get_user_info method at request manager<commit_after># stdlib
from datetime import datetime
from typing import Any
from typing import Dict

# third party
from sqlalchemy.engine import Engine
from sqlalchemy.orm import sessionmaker

# relative
from ....common.uid import UID
from ..exceptions import RequestError
from ..node_service.request_receiver.request_receiver_messages import RequestStatus
from ..node_table.request import Request
from .database_manager import DatabaseManager


class RequestManager(DatabaseManager):

    schema = Request

    def __init__(self, database: Engine) -> None:
        super().__init__(schema=RequestManager.schema, db=database)

    def first(self, **kwargs: Any) -> Request:
        result = super().first(**kwargs)
        if not result:
            raise RequestError

        return result

    def create_request(self, **kwargs) -> Request:
        date = datetime.now()
        return self.register(id=str(UID().value), date=date, **kwargs)

    def status(self, request_id: str) -> RequestStatus:
        _req = self.first(id=request_id)
        if _req.status == "pending":
            return RequestStatus.Pending
        elif _req.status == "accepted":
            return RequestStatus.Accepted
        else:
            return RequestStatus.Rejected

    def set(self, request_id: int, status: RequestStatus) -> None:
        self.modify({"id": request_id}, {"status": status})

    def get_user_info(request_id: int) -> Dict:
        request = super().first(id=request_id)
        return {
            "name": request.user_name,
            "email": request.user_email,
            "role": request.user_role,
            "budget": request.user_budget,
            "institution": request.institution,
            "website": request.website,
        }

    def clear(self) -> None:
        local_session = sessionmaker(bind=self.db)()
        local_session.query(self.schema).delete()
        local_session.commit()
        local_session.close()
{'fraction_non_alphanumeric': 0.09837242699856391, 'fraction_numerical': 0.0, 'mean_word_length': 2.6339130434782607, 'pattern_counts': {'":': 14, '<': 3, '<?xml version=': 0, '>': 16, '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': '3874017', 'n_tokens_mistral': 1158, 'n_tokens_neox': 1129, 'n_words': 295}