mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-06-02 19:55:18 +02:00
refactor: remove chat-related fields and legacy podcast generation function
This commit is contained in:
parent
c2dcb2045d
commit
1cbb1b5d66
5 changed files with 50 additions and 20 deletions
|
|
@ -0,0 +1,48 @@
|
|||
"""50_remove_podcast_chat_columns
|
||||
|
||||
Revision ID: 50
|
||||
Revises: 49
|
||||
Create Date: 2025-12-21
|
||||
|
||||
Removes chat_id and chat_state_version columns from podcasts table.
|
||||
These columns were used for the old chat system podcast linking which
|
||||
has been replaced by the new-chat content-based podcast generation.
|
||||
"""
|
||||
|
||||
from collections.abc import Sequence
|
||||
|
||||
import sqlalchemy as sa
|
||||
from sqlalchemy import inspect
|
||||
|
||||
from alembic import op
|
||||
|
||||
# revision identifiers, used by Alembic.
|
||||
revision: str = "50"
|
||||
down_revision: str | None = "49"
|
||||
branch_labels: str | Sequence[str] | None = None
|
||||
depends_on: str | Sequence[str] | None = None
|
||||
|
||||
|
||||
def upgrade() -> None:
|
||||
"""Upgrade schema - Remove chat_id and chat_state_version from podcasts."""
|
||||
conn = op.get_bind()
|
||||
inspector = inspect(conn)
|
||||
columns = [col["name"] for col in inspector.get_columns("podcasts")]
|
||||
|
||||
if "chat_id" in columns:
|
||||
op.drop_column("podcasts", "chat_id")
|
||||
|
||||
if "chat_state_version" in columns:
|
||||
op.drop_column("podcasts", "chat_state_version")
|
||||
|
||||
|
||||
def downgrade() -> None:
|
||||
"""Downgrade schema - Re-add chat_id and chat_state_version to podcasts."""
|
||||
op.add_column(
|
||||
"podcasts",
|
||||
sa.Column("chat_id", sa.Integer(), nullable=True),
|
||||
)
|
||||
op.add_column(
|
||||
"podcasts",
|
||||
sa.Column("chat_state_version", sa.String(100), nullable=True),
|
||||
)
|
||||
|
|
@ -436,10 +436,6 @@ class Podcast(BaseModel, TimestampMixin):
|
|||
)
|
||||
search_space = relationship("SearchSpace", back_populates="podcasts")
|
||||
|
||||
# Optional: link to chat thread (null for content-based podcasts from new-chat)
|
||||
chat_id = Column(Integer, nullable=True)
|
||||
chat_state_version = Column(String(100), nullable=True)
|
||||
|
||||
|
||||
class SearchSpace(BaseModel, TimestampMixin):
|
||||
__tablename__ = "searchspaces"
|
||||
|
|
|
|||
|
|
@ -13,8 +13,6 @@ class PodcastBase(BaseModel):
|
|||
podcast_transcript: list[dict[str, Any]] | None = None
|
||||
file_location: str | None = None
|
||||
search_space_id: int
|
||||
chat_id: int | None = None
|
||||
chat_state_version: str | None = None
|
||||
|
||||
|
||||
class PodcastCreate(PodcastBase):
|
||||
|
|
|
|||
|
|
@ -72,8 +72,7 @@ def generate_content_podcast_task(
|
|||
"""
|
||||
Celery task to generate podcast from source content (for new-chat).
|
||||
|
||||
Unlike generate_chat_podcast which requires a chat_id, this task
|
||||
generates a podcast directly from provided content.
|
||||
This task generates a podcast directly from provided content.
|
||||
|
||||
Args:
|
||||
source_content: The text content to convert into a podcast
|
||||
|
|
@ -164,8 +163,6 @@ async def _generate_content_podcast(
|
|||
podcast_transcript=serializable_transcript,
|
||||
file_location=file_path,
|
||||
search_space_id=search_space_id,
|
||||
chat_id=None, # No chat_id for new-chat podcasts
|
||||
chat_state_version=None,
|
||||
)
|
||||
session.add(podcast)
|
||||
await session.commit()
|
||||
|
|
|
|||
|
|
@ -7,19 +7,10 @@ if called. Use generate_content_podcast_task in celery_tasks/podcast_tasks.py
|
|||
for new-chat podcast generation instead.
|
||||
"""
|
||||
|
||||
from sqlalchemy.ext.asyncio import AsyncSession
|
||||
|
||||
from app.db import Podcast # noqa: F401 - imported for backwards compatibility
|
||||
|
||||
|
||||
async def generate_chat_podcast(
|
||||
session: AsyncSession,
|
||||
chat_id: int,
|
||||
search_space_id: int,
|
||||
user_id: int,
|
||||
podcast_title: str | None = None,
|
||||
user_prompt: str | None = None,
|
||||
):
|
||||
async def generate_chat_podcast(*args, **kwargs):
|
||||
"""
|
||||
Legacy function for generating podcasts from old chat system.
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue