<commit_before>"""Defines a command message that performs a bulk re-queue operation"""
from __future__ import unicode_literals

import logging

from job.models import Job
from messaging.messages.message import CommandMessage
from queue.messages.queued_jobs import QueuedJob
from queue.messages.requeue_jobs import create_requeue_jobs_messages
from util.parse import datetime_to_string, parse_datetime

# How many jobs to handle in a single execution of this message
MAX_BATCH_SIZE = 1000


logger = logging.getLogger(__name__)


def create_requeue_jobs_bulk_message(started=None, ended=None, error_categories=None, error_ids=None, job_ids=None,
                                     job_type_ids=None, priority=None, status=None):
    """Creates a message to perform a bulk job re-queue operation. The parameters are applied as filters to the jobs
    affected by the re-queue.

    :param started: The start time of the jobs
    :type started: :class:`datetime.datetime`
    :param ended: The end time of the jobs
    :type ended: :class:`datetime.datetime`
    :param error_categories: A list of error categories
    :type error_categories: list
    :param error_ids: A list of error IDs
    :type error_ids: list
    :param job_ids: A list of job IDs
    :type job_ids: list
    :param job_type_ids: A list of job type IDs
    :type job_type_ids: list
    :param priority: A new priority for the re-queued jobs
    :type priority: int
    :param status: The job status
    :type status: str
    :return: The message
    :rtype: :class:`queue.messages.requeue_jobs_bulk.RequeueJobsBulk`
    """

    message = RequeueJobsBulk()
    message.started = started
    message.ended = ended
    message.error_categories = error_categories
    message.error_ids = error_ids
    message.job_ids = job_ids
    message.job_type_ids = job_type_ids
    message.priority = priority
    message.status = status

    return message


class RequeueJobsBulk(CommandMessage):
    """Command message that sets performs a bulk re-queue operation
    """

    def __init__(self):
        """Constructor
        """

        super(RequeueJobsBulk, self).__init__('requeue_jobs_bulk')

        self.current_job_id = None  # Keeps track of where the bulk operation is
        self.started = None
        self.ended = None
        self.error_categories = None
        self.error_ids = None
        self.job_ids = None
        self.job_type_ids = None
        self.priority = None
        self.status = None
<commit_msg>Docstring fix<commit_after>"""Defines a command message that performs a bulk re-queue operation"""
from __future__ import unicode_literals

import logging

from job.models import Job
from messaging.messages.message import CommandMessage
from queue.messages.queued_jobs import QueuedJob
from queue.messages.requeue_jobs import create_requeue_jobs_messages
from util.parse import datetime_to_string, parse_datetime

# How many jobs to handle in a single execution of this message
MAX_BATCH_SIZE = 1000


logger = logging.getLogger(__name__)


def create_requeue_jobs_bulk_message(started=None, ended=None, error_categories=None, error_ids=None, job_ids=None,
                                     job_type_ids=None, priority=None, status=None):
    """Creates a message to perform a bulk job re-queue operation. The parameters are applied as filters to the jobs
    affected by the re-queue.

    :param started: The start time of the jobs
    :type started: :class:`datetime.datetime`
    :param ended: The end time of the jobs
    :type ended: :class:`datetime.datetime`
    :param error_categories: A list of error categories
    :type error_categories: list
    :param error_ids: A list of error IDs
    :type error_ids: list
    :param job_ids: A list of job IDs
    :type job_ids: list
    :param job_type_ids: A list of job type IDs
    :type job_type_ids: list
    :param priority: A new priority for the re-queued jobs
    :type priority: int
    :param status: The job status
    :type status: str
    :return: The message
    :rtype: :class:`queue.messages.requeue_jobs_bulk.RequeueJobsBulk`
    """

    message = RequeueJobsBulk()
    message.started = started
    message.ended = ended
    message.error_categories = error_categories
    message.error_ids = error_ids
    message.job_ids = job_ids
    message.job_type_ids = job_type_ids
    message.priority = priority
    message.status = status

    return message


class RequeueJobsBulk(CommandMessage):
    """Command message that performs a bulk re-queue operation
    """

    def __init__(self):
        """Constructor
        """

        super(RequeueJobsBulk, self).__init__('requeue_jobs_bulk')

        self.current_job_id = None  # Keeps track of where the bulk operation is
        self.started = None
        self.ended = None
        self.error_categories = None
        self.error_ids = None
        self.job_ids = None
        self.job_type_ids = None
        self.priority = None
        self.status = None

{'fraction_non_alphanumeric': 0.06903471804134056, 'fraction_numerical': 0.0016054585591009432, 'mean_word_length': 3.2634730538922154, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7308359', 'n_tokens_mistral': 1472, 'n_tokens_neox': 1407, 'n_words': 470}