<commit_before>from sciroccoclient.http.base import Base
from sciroccoclient.responses import ClientMessageResponse
from sciroccoclient.systemdata import SystemDataHTTPHeaders


class MessageQueueDAO(Base):
    def __init__(self, request_adapter):
        super().__init__()
        self.request_adapter = request_adapter
        self.end_point = '/messageQueue'

    def pull(self):

        request_response = self.request_adapter.request('GET', self.end_point)

        if request_response.http_status is 200:
            ro = ClientMessageResponse()
            ro.system_data = request_response.system_data
            ro.message_data = request_response.message_data

            return ro
        elif request_response.http_status is 204:
            return None
        else:
            raise SystemError

    def push(self, id, msg):
        request_response = self.request_adapter.request('POST', self.end_point, msg, {
            SystemDataHTTPHeaders.id: id
        })

        if request_response.http_status is 201:
            ro = ClientMessageResponse()
            ro.system_data = request_response.system_data
            ro.message_data = request_response.message_data
            return ro
        else:
            raise SystemError

    def ack(self, msg_id):
        request_response = self.request_adapter.request('PATCH', ''.join([self.end_point, '/', msg_id, '/ack']))

        if request_response.http_status == 200:<commit_msg>Refacto session, messagedao now uses message descriptor.<commit_after>from sciroccoclient.http.base import Base
from sciroccoclient.responses import ClientMessageResponse


class MessageQueueDAO(Base):
    def __init__(self, request_adapter, system_data_descriptor):
        super().__init__()
        self.request_adapter = request_adapter
        self.system_data_descriptor = system_data_descriptor
        self.end_point = '/messageQueue'

    def pull(self):

        request_response = self.request_adapter.request('GET', self.end_point)

        if request_response.http_status is 200:
            ro = ClientMessageResponse()
            ro.system_data = request_response.system_data
            ro.message_data = request_response.message_data

            return ro
        elif request_response.http_status is 204:
            return None
        else:
            raise SystemError

    def push(self, destination, msg):
        request_response = self.request_adapter.request('POST', self.end_point, msg, {
            self.system_data_descriptor.get_by_name('to'): destination
        })

        if request_response.http_status is 201:
            ro = ClientMessageResponse()
            ro.system_data = request_response.system_data
            ro.message_data = request_response.message_data
            return ro
        else:
            raise SystemError

    def ack(self, msg_id):
        request_response = self.request_adapter.request('PATCH', ''.join([self.end_point, '/', msg_id, '/ack']))

        if request_response.http_status == 200:
{'fraction_non_alphanumeric': 0.0804369414101291, 'fraction_numerical': 0.007944389275074478, 'mean_word_length': 2.6541717049576783, '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': '1352581', 'n_tokens_mistral': 846, 'n_tokens_neox': 798, 'n_words': 172}