<commit_before>from django.db import models
from django.utils.translation import ugettext_lazy as _
from djorm_pgarray.fields import TextArrayField
from timedelta import fields as timedelta_fields

from recipi.utils.db.uuid import UUIDField


INGREDIENT_UNITS = {
    'mg': _('Milligram'),
    'g': _('Gram'),
    'kg': _('Kilogram'),

    # TODO: These are experimental, maybe we need something different
    #       for these kind of 'units'
    'sl': _('Slice'),
}


class Ingredient(models.Model):
    name = models.CharField(max_length=256)

    # TODO: There is tooooons more: http://ndb.nal.usda.gov/ndb/foods/show/3044
    # I tried to find the most important values for now (cg)
    # All fields allow values up to 9999.99 - I think this should suffice (cg)

    calories = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    carbohydrate = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    protein = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    saturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    polyunsaturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    monounsaturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    trans_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    cholesterol = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    sodium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    potassium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    fiber = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    sugar = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    vitamin_a = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    vitamin_c = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    calcium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    iron = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)


class RecipeIngredient(models.Model):
    # TODO: Figure out if this makes sense.
    # Currently this model would be used for simple ingredients such as
    # "one slice of brown bread" and more specific ingredients such as<commit_msg>Add note regarding vitamin a, c, calcium and iron values in 'Ingredient' model.<commit_after>from django.db import models
from django.utils.translation import ugettext_lazy as _
from djorm_pgarray.fields import TextArrayField
from timedelta import fields as timedelta_fields

from recipi.utils.db.uuid import UUIDField


INGREDIENT_UNITS = {
    'mg': _('Milligram'),
    'g': _('Gram'),
    'kg': _('Kilogram'),

    # TODO: These are experimental, maybe we need something different
    #       for these kind of 'units'
    'sl': _('Slice'),
}


class Ingredient(models.Model):
    name = models.CharField(max_length=256)

    # TODO: There is tooooons more: http://ndb.nal.usda.gov/ndb/foods/show/3044
    # I tried to find the most important values for now (cg)
    # All fields allow values up to 9999.99 - I think this should suffice (cg)

    calories = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    carbohydrate = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    protein = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    saturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    polyunsaturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    monounsaturated_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    trans_fat = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    cholesterol = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    sodium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    potassium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    fiber = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    sugar = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)

    # TODO: depending on the source we need to make sure to use those values
    # identically. E.g fatsecret.com gives these values only as a
    # "percentage of daily Calcium/Iron" etc based on a 2000 calorie diet.
    vitamin_a = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    vitamin_c = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    calcium = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)
    iron = models.DecimalField(max_digits=6, decimal_places=2, default=0.0)


class RecipeIngredient(models.Model):
    # TODO: Figure out if this makes sense.
    # Currently this model would be used for simple ingredients such as
    # "one slice of brown bread" and more specific ingredients such as
{'fraction_non_alphanumeric': 0.10682492581602374, 'fraction_numerical': 0.032838773491592484, 'mean_word_length': 4.804822043628014, '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': '6247539', 'n_tokens_mistral': 1790, 'n_tokens_neox': 1688, 'n_words': 403}