<commit_before>from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import division

from six.moves import input

from django.core.management import BaseCommand
from django.db.models import Q

from corehq.apps.accounting.models import (
    Subscription,
    SoftwarePlanEdition,
)
from corehq.apps.domain.models import Domain
from corehq.apps.es import CaseES, CaseSearchES
from corehq.pillows.case_search import (
    domains_needing_search_index,
    CaseSearchReindexerFactory,
)
from corehq.toggles import ECD_MIGRATED_DOMAINS, NAMESPACE_DOMAIN


class Command(BaseCommand):
    help = 'Enables the Case Search Index for Explore Case Data Report'

    def add_arguments(self, parser):
        parser.add_argument(
            '--bulk-num',
            action='store',
            dest='bulk_num',
            type=int,
            default=5,
            help='The number of domains to migrate in bulk (default functionality).'
        )
        parser.add_argument(
            '--domain',
            action='store',
            dest='domain',
            default=None,
            help='A single domain to migrate.'
        )
        parser.add_argument(
            '--status',
            action='store_true',
            dest='status',
            default=False,
            help='Show status of remaining domains.'
        )

    @staticmethod
    def _domains_in_explore_case_data_beta():
        relevant_subs = Subscription.visible_objects.filter(
            is_active=True,
            is_trial=False,
        ).filter(
            Q(plan_version__plan__edition=SoftwarePlanEdition.ADVANCED) |
            Q(plan_version__plan__edition=SoftwarePlanEdition.PRO) |
            Q(plan_version__plan__edition=SoftwarePlanEdition.ENTERPRISE)
        ).all()
        return [sub.subscriber.domain for sub in relevant_subs]

    @staticmethod
    def _migrated_domains():
        return domains_needing_search_index()

    def _get_domain_lists(self):
        migrated = self._migrated_domains()
        couch_domains = []
        remaining = []<commit_msg>only migrate PRO and ADVANCED customers<commit_after>from __future__ import absolute_import
from __future__ import unicode_literals
from __future__ import division

from six.moves import input

from django.core.management import BaseCommand
from django.db.models import Q

from corehq.apps.accounting.models import (
    Subscription,
    SoftwarePlanEdition,
)
from corehq.apps.domain.models import Domain
from corehq.apps.es import CaseES, CaseSearchES
from corehq.pillows.case_search import (
    domains_needing_search_index,
    CaseSearchReindexerFactory,
)
from corehq.toggles import ECD_MIGRATED_DOMAINS, NAMESPACE_DOMAIN


class Command(BaseCommand):
    help = 'Enables the Case Search Index for Explore Case Data Report'

    def add_arguments(self, parser):
        parser.add_argument(
            '--bulk-num',
            action='store',
            dest='bulk_num',
            type=int,
            default=5,
            help='The number of domains to migrate in bulk (default functionality).'
        )
        parser.add_argument(
            '--domain',
            action='store',
            dest='domain',
            default=None,
            help='A single domain to migrate.'
        )
        parser.add_argument(
            '--status',
            action='store_true',
            dest='status',
            default=False,
            help='Show status of remaining domains.'
        )

    @staticmethod
    def _domains_in_explore_case_data_beta():
        relevant_subs = Subscription.visible_objects.filter(
            is_active=True,
            is_trial=False,
        ).filter(
            Q(plan_version__plan__edition=SoftwarePlanEdition.ADVANCED) |
            Q(plan_version__plan__edition=SoftwarePlanEdition.PRO)
        ).all()
        return [sub.subscriber.domain for sub in relevant_subs]

    @staticmethod
    def _migrated_domains():
        return domains_needing_search_index()

    def _get_domain_lists(self):
        migrated = self._migrated_domains()
        couch_domains = []
        remaining = []
{'fraction_non_alphanumeric': 0.0784925588094095, 'fraction_numerical': 0.00048007681228996637, 'mean_word_length': 2.4987405541561714, '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': '982751', 'n_tokens_mistral': 1201, 'n_tokens_neox': 1175, 'n_words': 262}