<commit_before>from django.db import models
from django.contrib.auth.models import User


class Resource(models.Model):
    objective = models.CharField(max_length=40)
    votes = models.IntegerField(default=0)
    inappropriate_flags = models.IntegerField(default=0)
    url = models.CharField(max_length=250)
    notes = models.CharField(max_length=1000, blank=True)
    when_added = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return "Resource for %s: %s" % (self.objective, self.url)


class ResourceSubmission(models.Model):
    user = models.ForeignKey(User)
    resource = models.ForeignKey(Resource)
    RS_TYPE_CHOICES = (
        ('c', 'Creator'),
        ('v', 'Voter'),
        ('f', 'Flagger'),
    )
    type = models.CharField(max_length=1, choices=RS_TYPE_CHOICES, default='c')

    def __unicode__(self):
        return "%s/%s/%s" % (self.user, self.resource, self.type)<commit_msg>avoid multiple entries for the same objective/resource combination<commit_after>from django.db import models
from django.contrib.auth.models import User


class Resource(models.Model):
    objective = models.CharField(max_length=40)
    votes = models.IntegerField(default=0)
    inappropriate_flags = models.IntegerField(default=0)
    url = models.CharField(max_length=250)
    notes = models.CharField(max_length=1000, blank=True)
    when_added = models.DateTimeField(auto_now_add=True)

    def __unicode__(self):
        return "Resource for %s: %s" % (self.objective, self.url)

    class Meta:
        unique_together = ('objective', 'url')


class ResourceSubmission(models.Model):
    user = models.ForeignKey(User)
    resource = models.ForeignKey(Resource)
    RS_TYPE_CHOICES = (
        ('c', 'Creator'),
        ('v', 'Voter'),
        ('f', 'Flagger'),
    )
    type = models.CharField(max_length=1, choices=RS_TYPE_CHOICES, default='c')

    def __unicode__(self):
        return "%s/%s/%s" % (self.user, self.resource, self.type)
{'fraction_non_alphanumeric': 0.13137948458817586, 'fraction_numerical': 0.01212733703890854, 'mean_word_length': 3.876847290640394, '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': '4716226', 'n_tokens_mistral': 653, 'n_tokens_neox': 620, 'n_words': 123}