<commit_before>from django.db import models
from odk_logger.models import XForm
import os

def upload_to(instance, filename):
    return os.path.join(
        'docs',
        instance.user.username,
        filename
        )

def unique_type_for_form(xform, data_type, data_value=None):
    result = type_for_form(xform, data_type)
    if not len(result):
        result = MetaData(data_type=data_type, xform=xform)
        result.save()
    else:
        result = result[0]
    if data_value:
        result.data_value = data_value
        result.save()
    return result

def type_for_form(xform, data_type):
    return MetaData.objects.filter(xform=xform, data_type=data_type)

class MetaData(models.Model):
    xform = models.ForeignKey(XForm)
    data_type = models.CharField(max_length=255)
    data_value = models.CharField(max_length=255)
    data_file = models.FileField(upload_to=upload_to, null=True)

    @staticmethod
    def form_license(xform, data_value=None):<commit_msg>change upload_to to reflect new data store format<commit_after>from django.db import models
from odk_logger.models import XForm
import os

def upload_to(instance, filename):
    return os.path.join(
        instance.user.username,
        'docs',
        filename
        )

def unique_type_for_form(xform, data_type, data_value=None):
    result = type_for_form(xform, data_type)
    if not len(result):
        result = MetaData(data_type=data_type, xform=xform)
        result.save()
    else:
        result = result[0]
    if data_value:
        result.data_value = data_value
        result.save()
    return result

def type_for_form(xform, data_type):
    return MetaData.objects.filter(xform=xform, data_type=data_type)

class MetaData(models.Model):
    xform = models.ForeignKey(XForm)
    data_type = models.CharField(max_length=255)
    data_value = models.CharField(max_length=255)
    data_file = models.FileField(upload_to=upload_to, null=True)

    @staticmethod
    def form_license(xform, data_value=None):
{'fraction_non_alphanumeric': 0.09235352532274081, 'fraction_numerical': 0.006951340615690168, 'mean_word_length': 3.5795454545454546, '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': '3185996', 'n_tokens_mistral': 668, 'n_tokens_neox': 657, 'n_words': 132}