Files
warehouse13/app/models/artifact.py
Mondo Diaz 21347d8c65 Add tags prominence and SIM source grouping features
Database changes:
- Add sim_source_id column to artifacts table for grouping multiple artifacts
- Create Alembic migration (001_add_sim_source_id) for schema update
- Add Alembic env.py for migration support with environment-based DB URLs

API enhancements:
- Add sim_source_id parameter to upload endpoint
- Add sim_source_id filter to query endpoint
- Add new /grouped-by-sim-source endpoint for getting artifacts by group
- Update all API documentation to include sim_source_id

UI improvements:
- Make tags required field and more prominent in upload form
- Add tags display directly in artifacts table (below filename)
- Add SIM Source ID field in upload form with helper text for grouping
- Update table to show sim_source_id (falls back to test_suite if null)
- Tags now displayed as inline badges in main table view

Seed data updates:
- Generate sim_source_id for 70% of artifacts to demonstrate grouping
- Multiple artifacts can share same sim_source_id
- Improved seed data variety with tag combinations

Features:
- Tags are now prominently displayed in both table and detail views
- Multiple artifacts can be grouped by SIM source ID
- Users can filter/query by sim_source_id
- Backward compatible - existing artifacts without sim_source_id still work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-10-15 09:30:25 -05:00

42 lines
1.5 KiB
Python

from sqlalchemy import Column, String, Integer, DateTime, JSON, BigInteger, Text
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime
Base = declarative_base()
class Artifact(Base):
__tablename__ = "artifacts"
id = Column(Integer, primary_key=True, index=True)
filename = Column(String(500), nullable=False, index=True)
file_type = Column(String(50), nullable=False, index=True) # csv, json, binary, pcap
file_size = Column(BigInteger, nullable=False)
storage_path = Column(String(1000), nullable=False)
content_type = Column(String(100))
# Test metadata
test_name = Column(String(500), index=True)
test_suite = Column(String(500), index=True)
test_config = Column(JSON)
test_result = Column(String(50), index=True) # pass, fail, skip, error
# SIM source grouping - allows multiple artifacts per source
sim_source_id = Column(String(100), index=True) # Groups artifacts from same SIM source
# Additional metadata
custom_metadata = Column(JSON)
description = Column(Text)
tags = Column(JSON) # Array of tags for categorization
# Timestamps
created_at = Column(DateTime, default=datetime.utcnow, index=True)
updated_at = Column(DateTime, default=datetime.utcnow, onupdate=datetime.utcnow)
# Versioning
version = Column(String(50))
parent_id = Column(Integer, index=True) # For file versioning
def __repr__(self):
return f"<Artifact(id={self.id}, filename='{self.filename}', test_name='{self.test_name}')>"