<commit_before>from django.core.management.base import BaseCommand, CommandError
from company.models import Company
from reversion.models import Version


class Command(BaseCommand):
    help = 'Deletes empty revisions'

    def handle(self, *args, **options):
        companies = Company.objects.all()
        for company in companies:
            if company.name:
                print company.name.encode('UTF-8')
            versions = Version.objects.\
                filter(object_id_int=company.pk,
                       content_type_id=16,
                       revision__comment='Firma utworzona automatycznie na '
                                         'podstawie API ILiM',
                       revision__user__isnull=True)\
                .order_by('revision__date_created')
            first_record = True
            for version in versions:
                if first_record:
                    first_record=False
                else:
                    version.delete()
                    print '.',<commit_msg>deleting revision as well (as the foreign key is not cascade)<commit_after>from django.core.management.base import BaseCommand, CommandError
from company.models import Company
from reversion.models import Version


class Command(BaseCommand):
    help = 'Deletes empty revisions'

    def handle(self, *args, **options):
        companies = Company.objects.all()
        for company in companies:
            if company.name:
                print company.name.encode('UTF-8')
            versions = Version.objects.\
                filter(object_id_int=company.pk,
                       content_type_id=16,
                       revision__comment='Firma utworzona automatycznie na '
                                         'podstawie API ILiM',
                       revision__user__isnull=True)\
                .order_by('revision__date_created')
            first_record = True
            for version in versions:
                if first_record:
                    first_record=False
                else:
                    version.revision.delete()
                    version.delete()
                    print '.',
{'fraction_non_alphanumeric': 0.07103321033210332, 'fraction_numerical': 0.0027675276752767526, 'mean_word_length': 1.5577830188679245, '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': 4, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7243409', 'n_tokens_mistral': 529, 'n_tokens_neox': 496, 'n_words': 127}