<commit_before>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)
<commit_msg>Decided it was fine for the depth to be 1-based instead of 0-based, so we don't need to remove 1 from the length of the split path 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))
    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.11770623742454728, 'fraction_numerical': 0.004024144869215292, 'mean_word_length': 3.9974874371859297, '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': '3278750', 'n_tokens_mistral': 636, 'n_tokens_neox': 615, 'n_words': 136}