- Discovery modes: Sonic Twin, Era Bridge, Deep Cuts, Rising Artists - Discovery dial (Safe to Adventurous slider) - Block genres/moods exclusion - Thumbs down/dislike on recommendations - My Taste page with Genre DNA breakdown, audio feature meters, listening personality - Updated pricing: Free (5/week), Premium ($6.99/mo), Family ($12.99/mo coming soon) - Weekly rate limiting instead of daily - Alembic migration for new fields
41 lines
1.7 KiB
Python
41 lines
1.7 KiB
Python
from datetime import datetime, timezone
|
|
|
|
from sqlalchemy import String, Integer, Float, DateTime, ForeignKey, Text, Boolean
|
|
from sqlalchemy.orm import Mapped, mapped_column, relationship
|
|
|
|
from app.core.database import Base
|
|
|
|
|
|
class Recommendation(Base):
|
|
__tablename__ = "recommendations"
|
|
|
|
id: Mapped[int] = mapped_column(primary_key=True)
|
|
user_id: Mapped[int] = mapped_column(ForeignKey("users.id", ondelete="CASCADE"), index=True)
|
|
playlist_id: Mapped[int | None] = mapped_column(ForeignKey("playlists.id", ondelete="SET NULL"), nullable=True)
|
|
|
|
# Recommended track info
|
|
title: Mapped[str] = mapped_column(String(500))
|
|
artist: Mapped[str] = mapped_column(String(500))
|
|
album: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
spotify_id: Mapped[str | None] = mapped_column(String(255), nullable=True)
|
|
preview_url: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
image_url: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
bandcamp_url: Mapped[str | None] = mapped_column(String(500), nullable=True)
|
|
|
|
# AI explanation
|
|
reason: Mapped[str] = mapped_column(Text)
|
|
score: Mapped[float | None] = mapped_column(Float, nullable=True)
|
|
query: Mapped[str | None] = mapped_column(Text, nullable=True)
|
|
|
|
# User interaction
|
|
saved: Mapped[bool] = mapped_column(Boolean, default=False)
|
|
disliked: Mapped[bool] = mapped_column(Boolean, default=False, server_default="false")
|
|
created_at: Mapped[datetime] = mapped_column(
|
|
DateTime(timezone=True), default=lambda: datetime.now(timezone.utc)
|
|
)
|
|
|
|
user: Mapped["User"] = relationship(back_populates="recommendations")
|
|
|
|
|
|
from app.models.user import User # noqa: E402, F811
|