<commit_before>from django.db import models
from django.contrib.comments.models import Comment

class ThreadedComment(Comment):
    parent = models.ForeignKey('self', null=True, blank=True, default=None,
        related_name='children')
    level  = models.IntegerField(default=0)

    def save(self, force_insert=False, force_update=False):
        if self.parent:
            self.level = self.parent.level + 1
        super(ThreadedComment, self).save(force_insert=force_insert,
            force_update=force_update)<commit_msg>Removed the level field and added a path (ancestry) field.<commit_after>from django.db import models
from django.contrib.comments.models import Comment
from django.conf import settings

PATH_SEPARATOR = getattr(settings, 'COMMENT_PATH_SEPARATOR', '/')
PATH_DIGITS = getattr(settings, 'COMMENT_PATH_DIGITS', 10)

class ThreadedComment(Comment):
    parent = models.ForeignKey('self', null=True, blank=True, default=None,
        related_name='children')
    path = models.TextField(null=True, blank=True, db_index=True)
    
    def _get_depth(self):
        return len(self.path.split(PATH_SEPARATOR)) - 1
    depth = property(_get_depth)
    
    def save(self, *args, **kwargs):
        super(ThreadedComment, self).save(*args, **kwargs)
        path_list = [unicode(self.pk).zfill(PATH_DIGITS)]
        if self.parent:
            path_list.append(self.parent.path)
        self.path = PATH_SEPARATOR.join(path_list)
        super(ThreadedComment, self).save(*args, **kwargs)
{'fraction_non_alphanumeric': 0.11390728476821192, 'fraction_numerical': 0.0033112582781456954, 'mean_word_length': 4.003311258278146, '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': '7527767', 'n_tokens_mistral': 464, 'n_tokens_neox': 451, 'n_words': 93}