Refactor code structure for improved readability and maintainability

This commit is contained in:
JSC
2025-07-22 13:21:44 +02:00
parent 11796b1012
commit fefb7f7bf4
26 changed files with 1424 additions and 7 deletions

34
app/models/sound.py Normal file
View File

@@ -0,0 +1,34 @@
from typing import TYPE_CHECKING
from sqlmodel import Field, Relationship
from app.models.base import BaseModel
if TYPE_CHECKING:
from app.models.playlist_sound import PlaylistSound
from app.models.stream import Stream
class Sound(BaseModel, table=True):
"""Database model for a sound."""
type: str = Field(nullable=False)
name: str = Field(nullable=False)
filename: str = Field(nullable=False)
duration: int = Field(default=0, ge=0, nullable=False)
size: int = Field(default=0, ge=0, nullable=False)
hash: str = Field(nullable=False)
normalized_filename: str | None = Field(default=None)
normalized_duration: int | None = Field(default=None, ge=0)
normalized_size: int | None = Field(default=None, ge=0)
normalized_hash: str | None = Field(default=None)
thumbnail: str | None = Field(default=None)
play_count: int = Field(default=0, ge=0, nullable=False)
is_normalized: bool = Field(default=False, nullable=False)
is_music: bool = Field(default=False, nullable=False)
is_deletable: bool = Field(default=True, nullable=False)
# relationships
playlist_sounds: list["PlaylistSound"] = Relationship(back_populates="sound")
streams: list["Stream"] = Relationship(back_populates="sound")