"""Seed the canonical PEZAJOB job category taxonomy."""
from django.core.management.base import BaseCommand

from jobs.category_data import sync_pezajob_categories
from jobs.models import JobCategory


class Command(BaseCommand):
    help = 'Seed or refresh all 40 PEZAJOB job categories (and CV library categories)'

    def handle(self, *args, **options):
        created, updated, total = sync_pezajob_categories(deactivate_unknown=True)
        self.stdout.write(
            self.style.SUCCESS(
                f'Categories synced: {created} created, {updated} updated '
                f'({JobCategory.objects.filter(is_active=True).count()} active of {total} canonical).'
            )
        )
