feat: add conversation_type and briefing_date to Conversation model
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -1,4 +1,6 @@
|
||||
from sqlalchemy import ForeignKey, Index, Integer, Text
|
||||
import datetime
|
||||
|
||||
from sqlalchemy import Date, ForeignKey, Index, Integer, Text
|
||||
from sqlalchemy import inspect
|
||||
from sqlalchemy.dialects.postgresql import JSONB
|
||||
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
||||
@@ -16,6 +18,11 @@ class Conversation(Base, TimestampMixin):
|
||||
)
|
||||
title: Mapped[str] = mapped_column(Text, default="")
|
||||
model: Mapped[str] = mapped_column(Text, default="")
|
||||
# 'chat' (default) or 'briefing'. Briefing conversations are hidden from
|
||||
# the main chat view and managed by the briefing pipeline.
|
||||
conversation_type: Mapped[str] = mapped_column(Text, default="chat", server_default="chat")
|
||||
# For briefing conversations only: the calendar date this briefing covers.
|
||||
briefing_date: Mapped[datetime.date | None] = mapped_column(Date, nullable=True)
|
||||
|
||||
messages: Mapped[list["Message"]] = relationship(
|
||||
back_populates="conversation",
|
||||
@@ -38,6 +45,8 @@ class Conversation(Base, TimestampMixin):
|
||||
"id": self.id,
|
||||
"title": self.title,
|
||||
"model": self.model,
|
||||
"conversation_type": self.conversation_type,
|
||||
"briefing_date": self.briefing_date.isoformat() if self.briefing_date else None,
|
||||
"message_count": msg_count,
|
||||
"created_at": self.created_at.isoformat(),
|
||||
"updated_at": self.updated_at.isoformat(),
|
||||
|
||||
@@ -0,0 +1,20 @@
|
||||
def test_conversation_has_briefing_fields():
|
||||
"""Conversation model must declare conversation_type and briefing_date."""
|
||||
from fabledassistant.models.conversation import Conversation
|
||||
cols = {c.key for c in Conversation.__table__.columns}
|
||||
assert "conversation_type" in cols
|
||||
assert "briefing_date" in cols
|
||||
|
||||
|
||||
def test_rss_models_exist():
|
||||
from fabledassistant.models.rss_feed import RssFeed, RssItem
|
||||
feed_cols = {c.key for c in RssFeed.__table__.columns}
|
||||
item_cols = {c.key for c in RssItem.__table__.columns}
|
||||
assert {"id", "user_id", "url", "title", "last_fetched_at"} <= feed_cols
|
||||
assert {"id", "feed_id", "guid", "title", "url", "published_at", "content"} <= item_cols
|
||||
|
||||
|
||||
def test_weather_cache_model_exists():
|
||||
from fabledassistant.models.weather_cache import WeatherCache
|
||||
cols = {c.key for c in WeatherCache.__table__.columns}
|
||||
assert {"id", "user_id", "location_key", "location_label", "forecast_json", "previous_json", "fetched_at"} <= cols
|
||||
Reference in New Issue
Block a user