<commit_before># -*- coding: utf-8 -*-

"""
byceps.services.shop.sequence.models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from enum import Enum

from sqlalchemy.ext.hybrid import hybrid_property

from ....blueprints.party.models import Party
from ....database import db
from ....util.instances import ReprBuilder


class PartySequencePrefix(db.Model):
    """A set of party-specific sequence number prefixes."""
    __tablename__ = 'shop_party_sequences_prefixes'

    party_id = db.Column(db.Unicode(20), db.ForeignKey('parties.id'), primary_key=True)
    party = db.relationship(Party, backref=db.backref('shop_number_prefix', uselist=False))
    article_number = db.Column(db.Unicode(20), unique=True, nullable=False)
    order_number = db.Column(db.Unicode(20), unique=True, nullable=False)

    def __init__(self, party_id, article_number_prefix, order_number_prefix):
        self.party_id = party_id
        self.article_number = article_number_prefix
        self.order_number = order_number_prefix

    def __repr__(self):
        return ReprBuilder(self) \
            .add('party', self.party_id) \
            .add_with_lookup('article_number') \
            .add_with_lookup('order_number') \
            .build()


PartySequencePurpose = Enum('PartySequencePurpose', ['article', 'order'])


class PartySequence(db.Model):
    """A sequence for a party and a purpose."""
    __tablename__ = 'shop_party_sequences'

    party_id = db.Column(db.Unicode(20), db.ForeignKey('parties.id'), primary_key=True)
    party = db.relationship(Party)
    _purpose = db.Column('purpose', db.Unicode(20), primary_key=True)
    value = db.Column(db.Integer, default=0, nullable=False)

    def __init__(self, party_id, purpose):
        self.party_id = party_id
        self.purpose = purpose

    @hybrid_property
    def purpose(self):
        return PartySequencePurpose[self._purpose]

    @purpose.setter
    def purpose(self, purpose):
        assert purpose is not None
        self._purpose = purpose.name

    def __repr__(self):
        return ReprBuilder(self) \<commit_msg>Remove relationships between party and sequence models<commit_after># -*- coding: utf-8 -*-

"""
byceps.services.shop.sequence.models
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

:Copyright: 2006-2016 <NAME>
:License: Modified BSD, see LICENSE for details.
"""

from enum import Enum

from sqlalchemy.ext.hybrid import hybrid_property

from ....database import db
from ....util.instances import ReprBuilder


class PartySequencePrefix(db.Model):
    """A set of party-specific sequence number prefixes."""
    __tablename__ = 'shop_party_sequences_prefixes'

    party_id = db.Column(db.Unicode(20), db.ForeignKey('parties.id'), primary_key=True)
    article_number = db.Column(db.Unicode(20), unique=True, nullable=False)
    order_number = db.Column(db.Unicode(20), unique=True, nullable=False)

    def __init__(self, party_id, article_number_prefix, order_number_prefix):
        self.party_id = party_id
        self.article_number = article_number_prefix
        self.order_number = order_number_prefix

    def __repr__(self):
        return ReprBuilder(self) \
            .add('party', self.party_id) \
            .add_with_lookup('article_number') \
            .add_with_lookup('order_number') \
            .build()


PartySequencePurpose = Enum('PartySequencePurpose', ['article', 'order'])


class PartySequence(db.Model):
    """A sequence for a party and a purpose."""
    __tablename__ = 'shop_party_sequences'

    party_id = db.Column(db.Unicode(20), db.ForeignKey('parties.id'), primary_key=True)
    _purpose = db.Column('purpose', db.Unicode(20), primary_key=True)
    value = db.Column(db.Integer, default=0, nullable=False)

    def __init__(self, party_id, purpose):
        self.party_id = party_id
        self.purpose = purpose

    @hybrid_property
    def purpose(self):
        return PartySequencePurpose[self._purpose]

    @purpose.setter
    def purpose(self, purpose):
        assert purpose is not None
        self._purpose = purpose.name

    def __repr__(self):
        return ReprBuilder(self) \
{'fraction_non_alphanumeric': 0.13287213740458015, 'fraction_numerical': 0.009541984732824428, 'mean_word_length': 3.6382743362831858, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '6873860', 'n_tokens_mistral': 1333, 'n_tokens_neox': 1247, 'n_words': 274}