- Implemented VLC player API endpoints for playing and stopping sounds. - Added tests for successful playback, error handling, and authentication scenarios. - Created utility function to get sound file paths based on sound properties. - Refactored player service to utilize shared sound path utility. - Enhanced test coverage for sound file path utility with various sound types. - Introduced tests for VLC player service, including subprocess handling and play count tracking.
23 lines
662 B
Python
23 lines
662 B
Python
from typing import TYPE_CHECKING
|
|
|
|
from sqlmodel import Field, Relationship
|
|
|
|
from app.models.base import BaseModel
|
|
|
|
if TYPE_CHECKING:
|
|
from app.models.sound import Sound
|
|
from app.models.user import User
|
|
|
|
|
|
class SoundPlayed(BaseModel, table=True):
|
|
"""Database model for a sound played."""
|
|
|
|
__tablename__ = "sound_played" # pyright: ignore[reportAssignmentType]
|
|
|
|
user_id: int | None = Field(foreign_key="user.id", nullable=True)
|
|
sound_id: int = Field(foreign_key="sound.id", nullable=False)
|
|
|
|
# relationships
|
|
user: "User" = Relationship(back_populates="sounds_played")
|
|
sound: "Sound" = Relationship(back_populates="play_history")
|