Initial commit: RSS platform phase 1 skeleton with code review fixes
Features: - FastAPI + SQLAlchemy 2.0 async + PostgreSQL/pgvector + Redis backend - Vue 3 + TypeScript + Element Plus frontend - JWT auth with access/refresh tokens and revocation - Admin/member RBAC - RSS feed CRUD and article listing - Settings management with Fernet encryption for sensitive values - Redis distributed lock service - Alembic initial migration - Docker Compose development environment Fixes from code review: - Fix DB session leak in dependency injection - Restrict registration to admin only - Add default admin password warning - Implement JWT refresh tokens and jti blacklist - Strengthen password policy - Use func.count for pagination totals - Replace NullPool with AsyncAdaptedQueuePool - Remove init_db from lifespan to enforce alembic migrations - Add request_id middleware and logging filter - Fix vite.config.ts env loading - Add frontend token refresh interceptor - Add Vue error handler Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,39 @@
|
||||
"""Reference and duplicate group models."""
|
||||
from sqlalchemy import Float, ForeignKey, JSON, String
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
|
||||
from app.models.base import Base, TimestampMixin, UUIDMixin
|
||||
|
||||
|
||||
class ArticleReference(Base, UUIDMixin, TimestampMixin):
|
||||
"""Reference from a cleaned article to another related article."""
|
||||
|
||||
__tablename__ = "article_references"
|
||||
|
||||
source_article_id: Mapped[str] = mapped_column(
|
||||
ForeignKey("cleaned_articles.id", ondelete="CASCADE"), nullable=False, index=True
|
||||
)
|
||||
referenced_article_id: Mapped[str | None] = mapped_column(
|
||||
ForeignKey("cleaned_articles.id", ondelete="SET NULL"), nullable=True, index=True
|
||||
)
|
||||
reference_type: Mapped[str] = mapped_column(String(64), nullable=False, index=True)
|
||||
reference_link: Mapped[str | None] = mapped_column(String(2048), default="")
|
||||
reference_title: Mapped[str | None] = mapped_column(String(1024), default="")
|
||||
similarity: Mapped[float | None] = mapped_column(Float, nullable=True)
|
||||
|
||||
|
||||
class DuplicateGroup(Base, UUIDMixin, TimestampMixin):
|
||||
"""Group of duplicate articles."""
|
||||
|
||||
__tablename__ = "duplicate_groups"
|
||||
|
||||
representative_article_id: Mapped[str | None] = mapped_column(
|
||||
ForeignKey("cleaned_articles.id", ondelete="SET NULL"), nullable=True, index=True
|
||||
)
|
||||
member_article_ids: Mapped[list] = mapped_column(JSON, default=list, nullable=False)
|
||||
similarity_matrix: Mapped[dict] = mapped_column(JSON, default=dict, nullable=False)
|
||||
brief_date: Mapped[str | None] = mapped_column(String(10), default="", index=True)
|
||||
|
||||
articles: Mapped[list["CleanedArticle"]] = relationship(
|
||||
"CleanedArticle", back_populates="duplicate_group"
|
||||
)
|
||||
Reference in New Issue
Block a user