# Path: api_v3/models/queue_job.py
# class QueueJob(models.Model):
#     class Meta:


import logging
from distutils.util import strtobool
from django.core.management.base import BaseCommand
from django.conf import settings
from api_v3.models.queue_job import QueueJob, queue



class Command(BaseCommand):
    help = 'Starts the jobs queue'

    def add_arguments(self, parser):
        parser.add_argument(
            '--inspect',
            help='Shows pending jobs in queue (includes processed on `True`).'
        )
        parser.add_argument(
            '--clean',
            help='Removes processed jobs.'
        )

    def handle(self, *args, **options):
        """Runs the queue."""
        if options['clean']:
            deleted = QueueJob.objects.filter(
                dequeued_at__isnull=False
            ).delete()

            self.stdout.write('Removed {0} jobs.'.format(deleted[0]))

            return None

        if options['inspect'] is not None:

# Path: api_v3/models/queue_job.py
# class QueueJob(models.Model):
#     class Meta:


# Path: api_v3/management/commands/queue.py
import logging
from distutils.util import strtobool
from django.core.management.base import BaseCommand
from django.conf import settings
from api_v3.models.queue_job import QueueJob, queue




class Command(BaseCommand):
    help = 'Starts the jobs queue'

    def add_arguments(self, parser):
        parser.add_argument(
            '--inspect',
            help='Shows pending jobs in queue (includes processed on `True`).'
        )
        parser.add_argument(
            '--clean',
            help='Removes processed jobs.'
        )

    def handle(self, *args, **options):
        """Runs the queue."""
        if options['clean']:
            deleted = QueueJob.objects.filter(
                dequeued_at__isnull=False
            ).delete()

            self.stdout.write('Removed {0} jobs.'.format(deleted[0]))

            return None

        if options['inspect'] is not None:

            jobs = QueueJob.objects.filter(