<commit_before>import sys
import time

from south.db import db
from django.db import models, transaction
from ella.oldcomments.models import *

from threadedcomments.models import ThreadedComment, PATH_DIGITS, PATH_SEPARATOR, MAX_PATH_LENGTH

class Migration:
    
    def forwards(self, orm):
        "Write your forwards migration here"
        transaction.commit_unless_managed()
        transaction.enter_transaction_management()
        transaction.managed(True)

        start = time.time()
        map = {}
        lc = {}
        for tc in ThreadedComment.objects.filter(tree_path='').order_by('id').iterator():
            path_leaf = unicode(tc.pk).zfill(PATH_DIGITS)
            if tc.parent_id:
                parent_path = map[tc.parent_id]
                tree_path = PATH_SEPARATOR.join((parent_path, path_leaf))

                # XXX if tree_path is longer than fits into the DB field, make it reply
                # to it's grandparent. A hack for improbable situation
                while len(tree_path) > MAX_PATH_LENGTH:
                    tree_path = tree_path.rsplit(PATH_SEPARATOR, 1)[0]

                lc[tc.parent_id] = tc.pk
            else:
                tree_path = path_leaf

            ThreadedComment.objects.filter(pk=tc.pk).update(
                tree_path=tree_path)
        
            map[tc.id] = tree_path
            sys.stdout.write('.')
        print 'OK'
        for par, child in lc.iteritems():
            ThreadedComment.objects.filter(pk=par).update(last_child=child)
            sys.stdout.write(':')
        print

        transaction.commit()
        transaction.leave_transaction_management()

    
    def backwards(self, orm):
        "Write your backwards migration here"
    
    
    models = {<commit_msg>MAX_PATH_LENGTH diappeared from threadedcomments, RIP<commit_after>import sys
import time

from south.db import db
from django.db import models, transaction
from ella.oldcomments.models import *

from threadedcomments.models import ThreadedComment, PATH_DIGITS, PATH_SEPARATOR

class Migration:
    
    def forwards(self, orm):
        "Write your forwards migration here"
        transaction.commit_unless_managed()
        transaction.enter_transaction_management()
        transaction.managed(True)

        start = time.time()
        map = {}
        lc = {}
        for tc in ThreadedComment.objects.filter(tree_path='').order_by('id').iterator():
            path_leaf = unicode(tc.pk).zfill(PATH_DIGITS)
            if tc.parent_id:
                parent_path = map[tc.parent_id]
                tree_path = PATH_SEPARATOR.join((parent_path, path_leaf))

                lc[tc.parent_id] = tc.pk
            else:
                tree_path = path_leaf

            ThreadedComment.objects.filter(pk=tc.pk).update(
                tree_path=tree_path)
        
            map[tc.id] = tree_path
            sys.stdout.write('.')
        print 'OK'
        for par, child in lc.iteritems():
            ThreadedComment.objects.filter(pk=par).update(last_child=child)
            sys.stdout.write(':')
        print

        transaction.commit()
        transaction.leave_transaction_management()

    
    def backwards(self, orm):
        "Write your backwards migration here"
    
    
    models = {
{'fraction_non_alphanumeric': 0.09007912355447352, 'fraction_numerical': 0.0006086427267194157, 'mean_word_length': 2.139446036294174, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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': '975141', 'n_tokens_mistral': 955, 'n_tokens_neox': 907, 'n_words': 199}