<commit_before>#!/usr/bin/env python3
#   encoding: UTF-8

from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy import UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.types import CHAR
from sqlalchemy.orm import relationship

Base = declarative_base()
metadata = Base.metadata


__doc__ = """
The schema module defines tables in the common database
"""


class Organisation(Base):
    __tablename__ = "organisations"

    id = Column("id", Integer, nullable=False, primary_key=True)
    name = Column("name", String(length=64), nullable=False, unique=True)

    hosts = relationship("Host")
    memberships = relationship("Membership")


class Artifact(Base):
    """
    This is the base table for all artifacts (products) of the system.

    Artifacts are created with globally unique `uuids` so their identity can
    be maintained across sharded databases.

    Concrete classes define their own tables according to SQLAlchemy's
    `joined-table inheritance`_.

    """
    __tablename__ = "artifacts"

    id = Column("id", Integer(), nullable=False, primary_key=True)
    typ = Column("typ", String(length=32), nullable=False)
    uuid = Column("uuid", CHAR(length=32), nullable=False)
    model = Column("model", String(length=32), nullable=False)
    changes = relationship("Touch", order_by="Touch.at")

    __mapper_args__ = {
        "polymorphic_identity": "artifact",
        "polymorphic_on": typ}


# TODO: revisit
class DCStatus(Artifact):
    __tablename__ = "dcstatus"

    id = Column("id", Integer, ForeignKey("artifacts.id"),
                nullable=False, primary_key=True)
    uri = Column("uri", String(length=128), nullable=False)
    name = Column("name", String(length=128), nullable=False)

    __mapper_args__ = {"polymorphic_identity": "dcstatus"}


class Membership(Artifact):
    """
    No user may interact with the system without specific membership
    privileges. The user accumulates credentials against a
    membership record. The membership defines the role a user may operate
    within an `organisation`.
    """
    __tablename__ = "memberships"<commit_msg>Some tidying and pruning<commit_after>#!/usr/bin/env python3
#   encoding: UTF-8

from sqlalchemy import Column
from sqlalchemy import DateTime
from sqlalchemy import ForeignKey
from sqlalchemy import Integer
from sqlalchemy import String
from sqlalchemy import UniqueConstraint
from sqlalchemy.ext.declarative import declarative_base
from sqlalchemy.types import CHAR
from sqlalchemy.orm import relationship

Base = declarative_base()
metadata = Base.metadata


__doc__ = """
The schema module defines tables in the common database
"""


class Organisation(Base):
    __tablename__ = "organisations"

    id = Column("id", Integer, nullable=False, primary_key=True)
    name = Column("name", String(length=64), nullable=False, unique=True)

    hosts = relationship("Host")
    memberships = relationship("Membership")


class Artifact(Base):
    """
    This is the base table for all artifacts (products) of the system.

    Artifacts are created with globally unique `uuids` so their identity can
    be maintained across sharded databases.

    Concrete classes define their own tables according to SQLAlchemy's
    `joined-table inheritance`_.

    """
    __tablename__ = "artifacts"

    id = Column("id", Integer(), nullable=False, primary_key=True)
    typ = Column("typ", String(length=32), nullable=False)
    uuid = Column("uuid", CHAR(length=32), nullable=False)
    model = Column("model", String(length=32), nullable=False)
    changes = relationship("Touch", order_by="Touch.at")

    __mapper_args__ = {
        "polymorphic_identity": "artifact",
        "polymorphic_on": typ}


class Membership(Artifact):
    """
    No user may interact with the system without specific membership
    privileges. The user accumulates credentials against a
    membership record. The membership defines the role a user may operate
    within an `organisation`.
    """
    __tablename__ = "memberships"
{'fraction_non_alphanumeric': 0.09587727708533078, 'fraction_numerical': 0.006232023010546501, 'mean_word_length': 4.336317135549872, 'pattern_counts': {'":': 5, '<': 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': '1752364', 'n_tokens_mistral': 1239, 'n_tokens_neox': 1150, 'n_words': 375}