<commit_before>from django.db import models
from django.core.urlresolvers import reverse

from mig_main.models import MemberProfile
from mig_main.templatetags.my_markdown import my_markdown
# Create your models here.
def get_user_points(memberprofile):
    point_objects = MessagePoint.objects.filter(message__creator=memberprofile)
    votes_count = 2*point_objects.filter(plus_point=True,message__hidden=False).count()-point_objects.filter(plus_point=False).count()
    spent_downvotes = MessagePoint.objects.filter(user=memberprofile,plus_point=False).count()
    posts_created = ForumMessage.objects.filter(creator=memberprofile,hidden=False).count()
    return 2+posts_created+votes_count-spent_downvotes
    
class Forum(models.Model):
    name = models.CharField(max_length=128)
    
    def get_first_threads(self):
        threads=self.forumthread_set.filter(hidden=False).order_by('time_created')
        return threads[:9]
class ForumThread(models.Model):
    title = models.CharField(max_length=256)
    forum = models.ForeignKey(Forum)
    creator=models.ForeignKey('mig_main.MemberProfile')
    time_created = models.DateTimeField(auto_now_add=True)
    hidden = models.BooleanField(default=False)
    
    def get_root_message(self):<commit_msg>Update models.py<commit_after>from django.db import models
from django.core.urlresolvers import reverse

from mig_main.models import MemberProfile
from mig_main.templatetags.my_markdown import my_markdown
# Create your models here.
def get_user_points(memberprofile):
    """
    Calculates the points associated with a particular user. This is based on the posts they've created, the number of up and down votes their posts
    have received, and the number of downcvotes they themselves have given.
    """
    point_objects = MessagePoint.objects.filter(message__creator=memberprofile)
    votes_count = 2*point_objects.filter(plus_point=True,message__hidden=False).count()-point_objects.filter(plus_point=False).count()
    spent_downvotes = MessagePoint.objects.filter(user=memberprofile,plus_point=False).count()
    posts_created = ForumMessage.objects.filter(creator=memberprofile,hidden=False).count()
    return 2+posts_created+votes_count-spent_downvotes
    
class Forum(models.Model):
    name = models.CharField(max_length=128)
    
    def get_first_threads(self):
        threads=self.forumthread_set.filter(hidden=False).order_by('-time_created')
        return threads[:9]
class ForumThread(models.Model):
    title = models.CharField(max_length=256)
    forum = models.ForeignKey(Forum)
    creator=models.ForeignKey('mig_main.MemberProfile')
    time_created = models.DateTimeField(auto_now_add=True)
    hidden = models.BooleanField(default=False)
    
    def get_root_message(self):
{'fraction_non_alphanumeric': 0.09367088607594937, 'fraction_numerical': 0.0065099457504520794, 'mean_word_length': 5.585714285714285, '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': '7410686', 'n_tokens_mistral': 837, 'n_tokens_neox': 823, 'n_words': 144}