Add stream dashboard ingestion
This commit is contained in:
@@ -35,6 +35,24 @@ class ChatMessage(Base):
|
||||
is_moderator = Column(Boolean, default=False)
|
||||
|
||||
|
||||
class StreamDashboard(Base):
|
||||
"""Stores the approved stream dashboard for a session."""
|
||||
|
||||
__tablename__ = "stream_dashboards"
|
||||
|
||||
session_id = Column(String, primary_key=True)
|
||||
raw_markdown = Column(Text, nullable=False)
|
||||
stream_title = Column(String, nullable=True)
|
||||
game = Column(String, nullable=True)
|
||||
mood = Column(String, nullable=True)
|
||||
go_live_notification = Column(Text, nullable=True)
|
||||
social_post = Column(Text, nullable=True)
|
||||
session_goals = Column(Text, nullable=True) # JSON array of strings
|
||||
content_angle = Column(Text, nullable=True)
|
||||
created_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
updated_at = Column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class AgentActionType(str, Enum):
|
||||
"""Types of actions the agent can take."""
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
"""Data access layer for database operations."""
|
||||
|
||||
import json
|
||||
import logging
|
||||
import uuid
|
||||
from datetime import datetime
|
||||
@@ -8,6 +9,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.memory.models import (
|
||||
StreamSession,
|
||||
StreamDashboard,
|
||||
ChatMessage,
|
||||
AgentAction,
|
||||
ClipCandidate,
|
||||
@@ -66,6 +68,61 @@ class Repository:
|
||||
result = await self.session.execute(stmt)
|
||||
return list(result.scalars().all())
|
||||
|
||||
# Stream Dashboard operations
|
||||
|
||||
async def upsert_dashboard(
|
||||
self,
|
||||
session_id: str,
|
||||
raw_markdown: str,
|
||||
stream_title: str | None = None,
|
||||
game: str | None = None,
|
||||
mood: str | None = None,
|
||||
go_live_notification: str | None = None,
|
||||
social_post: str | None = None,
|
||||
session_goals: list[str] | None = None,
|
||||
content_angle: str | None = None,
|
||||
) -> StreamDashboard:
|
||||
"""Create or update a stream dashboard for a session."""
|
||||
dashboard = await self.get_dashboard(session_id)
|
||||
now = datetime.utcnow()
|
||||
goals_json = json.dumps(session_goals or [])
|
||||
|
||||
if dashboard is None:
|
||||
dashboard = StreamDashboard(
|
||||
session_id=session_id,
|
||||
raw_markdown=raw_markdown,
|
||||
stream_title=stream_title,
|
||||
game=game,
|
||||
mood=mood,
|
||||
go_live_notification=go_live_notification,
|
||||
social_post=social_post,
|
||||
session_goals=goals_json,
|
||||
content_angle=content_angle,
|
||||
created_at=now,
|
||||
updated_at=now,
|
||||
)
|
||||
self.session.add(dashboard)
|
||||
else:
|
||||
dashboard.raw_markdown = raw_markdown
|
||||
dashboard.stream_title = stream_title
|
||||
dashboard.game = game
|
||||
dashboard.mood = mood
|
||||
dashboard.go_live_notification = go_live_notification
|
||||
dashboard.social_post = social_post
|
||||
dashboard.session_goals = goals_json
|
||||
dashboard.content_angle = content_angle
|
||||
dashboard.updated_at = now
|
||||
|
||||
await self.session.commit()
|
||||
logger.info(f"Saved dashboard for session {session_id}")
|
||||
return dashboard
|
||||
|
||||
async def get_dashboard(self, session_id: str) -> StreamDashboard | None:
|
||||
"""Retrieve the dashboard for a session."""
|
||||
stmt = select(StreamDashboard).where(StreamDashboard.session_id == session_id)
|
||||
result = await self.session.execute(stmt)
|
||||
return result.scalars().first()
|
||||
|
||||
# Chat Message operations
|
||||
|
||||
async def add_chat_message(
|
||||
|
||||
Reference in New Issue
Block a user