<commit_before>from sqlalchemy import Column, DateTime, Enum, Integer, String

from virtool.pg.utils import Base, SQLEnum


class ArtifactType(str, SQLEnum):
    """
    Enumerated type for possible artifact types

    """

    sam = "sam"
    bam = "bam"
    fasta = "fasta"
    fastq = "fastq"
    csv = "csv"
    tsv = "tsv"
    json = "json"


class SampleArtifact(Base):
    """
    SQL model to store sample artifacts

    """
    __tablename__ = "sample_artifacts"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String, nullable=False)
    name_on_disk = Column(String)
    size = Column(Integer)
    type = Column(Enum(ArtifactType), nullable=False)
    uploaded_at = Column(DateTime)


class SampleReadsFile(Base):
    """
    SQL model to store new sample reads files

    """
    __tablename__ = "sample_reads_files"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String(length=13), nullable=False)
    name_on_disk = Column(String, nullable=False)
    size = Column(Integer)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<SampleReadsFile(id={self.id}, sample={self.sample}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, size={self.size}, uploaded_at={self.uploaded_at})>"<commit_msg>Add `SampleArtifactCache` and `SampleReadsFileCache` SQL models<commit_after>from sqlalchemy import Column, DateTime, Enum, Integer, String

from virtool.pg.utils import Base, SQLEnum


class ArtifactType(str, SQLEnum):
    """
    Enumerated type for possible artifact types

    """

    sam = "sam"
    bam = "bam"
    fasta = "fasta"
    fastq = "fastq"
    csv = "csv"
    tsv = "tsv"
    json = "json"


class SampleArtifact(Base):
    """
    SQL model to store a sample artifact

    """
    __tablename__ = "sample_artifact"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String, nullable=False)
    name_on_disk = Column(String)
    size = Column(Integer)
    type = Column(Enum(ArtifactType), nullable=False)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<SampleArtifact(id={self.id}, sample={self.sample}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, size={self.size}, type={self.type}, " \
               f"uploaded_at={self.uploaded_at}"


class SampleReadsFile(Base):
    """
    SQL model to store new sample reads files

    """
    __tablename__ = "sample_reads_files"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String(length=13), nullable=False)
    name_on_disk = Column(String, nullable=False)
    size = Column(Integer)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<SampleReadsFile(id={self.id}, sample={self.sample}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, size={self.size}, uploaded_at={self.uploaded_at})>"


class SampleArtifactCache(Base):
    """
    SQL model to store a cached sample artifact

    """
    __tablename__ = "sample_artifact_cache"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String, nullable=False)
    name_on_disk = Column(String)
    size = Column(Integer)
    type = Column(Enum(ArtifactType), nullable=False)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<SampleArtifactCache(id={self.id}, sample={self.sample}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, size={self.size}, type={self.type}, " \
               f"uploaded_at={self.uploaded_at}"

    
class SampleReadsFileCache(Base):
    """
    SQL model to store cached sample reads files

    """
    __tablename__ = "sample_reads_files_cache"

    id = Column(Integer, primary_key=True)
    sample = Column(String, nullable=False)
    name = Column(String(length=13), nullable=False)
    name_on_disk = Column(String, nullable=False)
    size = Column(Integer)
    uploaded_at = Column(DateTime)

    def __repr__(self):
        return f"<SampleReadsFileCache(id={self.id}, sample={self.sample}, name={self.name}, " \
               f"name_on_disk={self.name_on_disk}, size={self.size}, uploaded_at={self.uploaded_at})>"
{'fraction_non_alphanumeric': 0.1271769019248396, 'fraction_numerical': 0.001374885426214482, 'mean_word_length': 3.518633540372671, 'pattern_counts': {'":': 0, '<': 8, '<?xml version=': 0, '>': 6, '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': '3797190', 'n_tokens_mistral': 1466, 'n_tokens_neox': 1416, 'n_words': 294}