<commit_before>"""
byceps.services.user_badge.models.awarding
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

from collections import namedtuple
from datetime import datetime

from ....database import db, generate_uuid
from ....typing import UserID

from .badge import BadgeID


BadgeAwardingTuple = namedtuple('BadgeAwardingTuple',
    'badge_id, user_id, awarded_at')


QuantifiedBadgeAwardingTuple = namedtuple('BadgeAwardingTuple',
    'badge_id, user_id, quantity')


class BadgeAwarding(db.Model):
    """The awarding of a badge to a user."""
    __tablename__ = 'user_badge_awardings'

    id = db.Column(db.Uuid, default=generate_uuid, primary_key=True)
    badge_id = db.Column(db.Uuid, db.ForeignKey('user_badges.id'), nullable=False)
    user_id = db.Column(db.Uuid, db.ForeignKey('users.id'), nullable=False)
    awarded_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)

    def __init__(self, badge_id: BadgeID, user_id: UserID) -> None:
        self.badge_id = badge_id
        self.user_id = user_id

    def to_tuple(self) -> BadgeAwardingTuple:
        """Return a tuple representation of this entity."""
        return BadgeAwardingTuple(
            self.badge_id,
            self.user_id,
            self.awarded_at
        )
<commit_msg>Include awarding ID in `BadgeAwardingTuple`<commit_after>"""
byceps.services.user_badge.models.awarding
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

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

from collections import namedtuple
from datetime import datetime

from ....database import db, generate_uuid
from ....typing import UserID

from .badge import BadgeID


BadgeAwardingTuple = namedtuple('BadgeAwardingTuple',
    'id, badge_id, user_id, awarded_at')


QuantifiedBadgeAwardingTuple = namedtuple('BadgeAwardingTuple',
    'badge_id, user_id, quantity')


class BadgeAwarding(db.Model):
    """The awarding of a badge to a user."""
    __tablename__ = 'user_badge_awardings'

    id = db.Column(db.Uuid, default=generate_uuid, primary_key=True)
    badge_id = db.Column(db.Uuid, db.ForeignKey('user_badges.id'), nullable=False)
    user_id = db.Column(db.Uuid, db.ForeignKey('users.id'), nullable=False)
    awarded_at = db.Column(db.DateTime, default=datetime.utcnow, nullable=False)

    def __init__(self, badge_id: BadgeID, user_id: UserID) -> None:
        self.badge_id = badge_id
        self.user_id = user_id

    def to_tuple(self) -> BadgeAwardingTuple:
        """Return a tuple representation of this entity."""
        return BadgeAwardingTuple(
            self.id,
            self.badge_id,
            self.user_id,
            self.awarded_at
        )

{'fraction_non_alphanumeric': 0.13667508113956003, 'fraction_numerical': 0.00576992426974396, 'mean_word_length': 3.8159722222222223, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 9, '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': '3216490', 'n_tokens_mistral': 947, 'n_tokens_neox': 904, 'n_words': 200}