feat: Add Extraction model and seed main playlist functionality

This commit is contained in:
JSC
2025-07-28 19:39:32 +02:00
parent 34e6289f92
commit c993230f98
8 changed files with 121 additions and 49 deletions

View File

@@ -9,7 +9,7 @@ if TYPE_CHECKING:
from app.models.user import User
class Stream(BaseModel, table=True):
class Extraction(BaseModel, table=True):
"""Database model for a stream."""
service: str = Field(nullable=False)
@@ -30,10 +30,10 @@ class Stream(BaseModel, table=True):
UniqueConstraint(
"service",
"service_id",
name="uq_stream_service_service_id",
name="uq_extraction_service_service_id",
),
)
# relationships
sound: "Sound" = Relationship(back_populates="streams")
user: "User" = Relationship(back_populates="streams")
sound: "Sound" = Relationship(back_populates="extractions")
user: "User" = Relationship(back_populates="extractions")

View File

@@ -5,9 +5,9 @@ from sqlmodel import Field, Relationship
from app.models.base import BaseModel
if TYPE_CHECKING:
from app.models.extraction import Extraction
from app.models.playlist_sound import PlaylistSound
from app.models.sound_played import SoundPlayed
from app.models.stream import Stream
class Sound(BaseModel, table=True):
@@ -31,5 +31,5 @@ class Sound(BaseModel, table=True):
# relationships
playlist_sounds: list["PlaylistSound"] = Relationship(back_populates="sound")
streams: list["Stream"] = Relationship(back_populates="sound")
extractions: list["Extraction"] = Relationship(back_populates="sound")
play_history: list["SoundPlayed"] = Relationship(back_populates="sound")

View File

@@ -6,10 +6,10 @@ from sqlmodel import Field, Relationship
from app.models.base import BaseModel
if TYPE_CHECKING:
from app.models.extraction import Extraction
from app.models.plan import Plan
from app.models.playlist import Playlist
from app.models.sound_played import SoundPlayed
from app.models.stream import Stream
from app.models.user_oauth import UserOauth
@@ -34,4 +34,4 @@ class User(BaseModel, table=True):
plan: "Plan" = Relationship(back_populates="users")
playlists: list["Playlist"] = Relationship(back_populates="user")
sounds_played: list["SoundPlayed"] = Relationship(back_populates="user")
streams: list["Stream"] = Relationship(back_populates="user")
extractions: list["Extraction"] = Relationship(back_populates="user")