<commit_before>from elixir import (
    Entity, Field, Unicode, UnicodeText, Integer, Interval, Float, Enum,
    DateTime, using_options, OneToMany, ManyToOne, entities
)
from draughtcraft.lib.calculations  import Calculations
from draughtcraft.lib.units         import UnitConvert
from draughtcraft.model.deepcopy    import DeepCopyMixin, ShallowCopyMixin
from uuid                           import uuid4 as uuid
from datetime                       import datetime
from copy                           import deepcopy


class Recipe(Entity, DeepCopyMixin, ShallowCopyMixin):

    TYPES = (
        'MASH',
        'EXTRACT',
        'EXTRACTSTEEP',
        'MINIMASH'
    )

    uuid                = Field(Unicode(64), index=True, default=lambda: unicode(uuid()))
    type                = Field(Enum(*TYPES), default='MASH')
    name                = Field(Unicode(256))
    gallons             = Field(Float, default=5)
    boil_minutes        = Field(Integer, default=60)
    notes               = Field(UnicodeText)
    creation_date       = Field(DateTime, default=datetime.utcnow)
    last_updated        = Field(DateTime, default=datetime.utcnow)

    head                = ManyToOne('Recipe', inverse='revisions')
    revisions           = OneToMany('Recipe', inverse='head')

    additions           = OneToMany('RecipeAddition', inverse='recipe')
    fermentation_steps  = OneToMany('FermentationStep', inverse='recipe')
    slugs               = OneToMany('RecipeSlug', inverse='recipe')
    style               = ManyToOne('Style', inverse='recipes')
    author              = ManyToOne('User', inverse='recipes')

    def __init__(self, **kwargs):
        super(Recipe, self).__init__(**kwargs)
        if kwargs.get('name') and not kwargs.get('slugs'):
            self.slugs.append(
                entities.RecipeSlug(name=kwargs['name'])
            )
<commit_msg>Adding chronological ordering to recipe revisions.<commit_after>from elixir import (
    Entity, Field, Unicode, UnicodeText, Integer, Interval, Float, Enum,
    DateTime, using_options, OneToMany, ManyToOne, entities
)
from draughtcraft.lib.calculations  import Calculations
from draughtcraft.lib.units         import UnitConvert
from draughtcraft.model.deepcopy    import DeepCopyMixin, ShallowCopyMixin
from uuid                           import uuid4 as uuid
from datetime                       import datetime
from copy                           import deepcopy


class Recipe(Entity, DeepCopyMixin, ShallowCopyMixin):

    TYPES = (
        'MASH',
        'EXTRACT',
        'EXTRACTSTEEP',
        'MINIMASH'
    )

    uuid                = Field(Unicode(64), index=True, default=lambda: unicode(uuid()))
    type                = Field(Enum(*TYPES), default='MASH')
    name                = Field(Unicode(256))
    gallons             = Field(Float, default=5)
    boil_minutes        = Field(Integer, default=60)
    notes               = Field(UnicodeText)
    creation_date       = Field(DateTime, default=datetime.utcnow)
    last_updated        = Field(DateTime, default=datetime.utcnow)

    head                = ManyToOne('Recipe', inverse='revisions')
    revisions           = OneToMany('Recipe', inverse='head', order_by='creation_date')

    additions           = OneToMany('RecipeAddition', inverse='recipe')
    fermentation_steps  = OneToMany('FermentationStep', inverse='recipe')
    slugs               = OneToMany('RecipeSlug', inverse='recipe')
    style               = ManyToOne('Style', inverse='recipes')
    author              = ManyToOne('User', inverse='recipes')

    def __init__(self, **kwargs):
        super(Recipe, self).__init__(**kwargs)
        if kwargs.get('name') and not kwargs.get('slugs'):
            self.slugs.append(
                entities.RecipeSlug(name=kwargs['name'])
            )

{'fraction_non_alphanumeric': 0.10425921087013326, 'fraction_numerical': 0.004703423046772929, 'mean_word_length': 2.317157712305026, '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': '5911398', 'n_tokens_mistral': 1111, 'n_tokens_neox': 1060, 'n_words': 224}