<commit_before>import datetime
from django.core.management import BaseCommand

from clients.models import Card, Individual
from rmis_integration.client import Client as RC


class Command(BaseCommand):
    help = "Синхронизация пациентов с РМИС"

    def handle(self, *args, **options):
        self.stdout.write("{:%Y-%m-%d %H:%M}".format(datetime.datetime.now()) + " - TRIGGER")

        objs = Card.objects.filter(napravleniya__isnull=True, is_archive=True)
        cnt = objs.count()
        _, cnt = objs.delete()
        cnt = cnt.get("clients.Card", 0)
        self.stdout.write("Архивных карт без направлений удалено: {}".format(cnt))

        objs = Individual.objects.filter(card__isnull=True)
        cnt = objs.count()
        _, cnt = objs.delete()
        cnt = cnt.get("clients.Individual", 0)
        self.stdout.write("Пацтентов без карт удалено: {}".format(cnt))

        c = RC()
        cds = Card.objects.filter(base__is_rmis=True, is_archive=False)
        count = cds.count()
        i = 0
        for card in cds:
            i += 1
            da = c.patients.sync_data(card)
            if da:
                self.stdout.write("Обработка карты {}/{}".format(i, count))
                self.stdout.write(da)
        self.stdout.write("OK")
<commit_msg>bugfix<commit_after>import datetime
from django.core.management import BaseCommand

from clients.models import Card, Individual
from rmis_integration.client import Client as RC


class Command(BaseCommand):
    help = "Синхронизация пациентов с РМИС"

    def handle(self, *args, **options):
        self.stdout.write("{:%Y-%m-%d %H:%M}".format(datetime.datetime.now()) + " - TRIGGER")

        objs = Card.objects.filter(napravleniya__isnull=True, is_archive=True)
        cnt = objs.count()
        _, cnt = objs.delete()
        cnt = cnt.get("clients.Card", 0)
        self.stdout.write("Архивных карт без направлений удалено: {}".format(cnt))

        objs = Individual.objects.filter(card__isnull=True)
        cnt = objs.count()
        _, cnt = objs.delete()
        cnt = cnt.get("clients.Individual", 0)
        self.stdout.write("Пацтентов без карт удалено: {}".format(cnt))

        c = RC()
        cds = Card.objects.filter(base__is_rmis=True, is_archive=False).exclude(base__is_rmis=False)
        count = cds.count()
        i = 0
        for card in cds:
            i += 1
            da = c.patients.sync_data(card)
            if da:
                self.stdout.write("Обработка карты {}/{}".format(i, count))
                self.stdout.write(da)
        self.stdout.write("OK")

{'fraction_non_alphanumeric': 0.13498836307214895, 'fraction_numerical': 0.0031031807602792862, 'mean_word_length': 2.494579945799458, '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': '5626395', 'n_tokens_mistral': 880, 'n_tokens_neox': 874, 'n_words': 172}