From fa81509c9f5a6daca624e73edd78010d1089e9b8 Mon Sep 17 00:00:00 2001 From: Bryan Van Deusen Date: Wed, 11 Mar 2026 19:45:47 -0400 Subject: [PATCH] feat: add conversation_type and briefing_date to Conversation model Co-Authored-By: Claude Sonnet 4.6 --- src/fabledassistant/models/conversation.py | 11 ++++++++++- tests/test_briefing_models.py | 20 ++++++++++++++++++++ 2 files changed, 30 insertions(+), 1 deletion(-) create mode 100644 tests/test_briefing_models.py diff --git a/src/fabledassistant/models/conversation.py b/src/fabledassistant/models/conversation.py index 0834d05..2613e67 100644 --- a/src/fabledassistant/models/conversation.py +++ b/src/fabledassistant/models/conversation.py @@ -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(), diff --git a/tests/test_briefing_models.py b/tests/test_briefing_models.py new file mode 100644 index 0000000..7f60e1d --- /dev/null +++ b/tests/test_briefing_models.py @@ -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