WIP: Add timestamp to comments and fix frontend errors

This commit is contained in:
Mistral Vibe
2026-03-29 22:06:36 +02:00
parent f7a07ba05e
commit a8aba72b3a
6 changed files with 139 additions and 6 deletions

View File

@@ -206,6 +206,7 @@ class SongComment(Base):
UUID(as_uuid=True), ForeignKey("members.id", ondelete="CASCADE"), nullable=False
)
body: Mapped[str] = mapped_column(Text, nullable=False)
timestamp: Mapped[Optional[float]] = mapped_column(Numeric(10, 2), nullable=True)
created_at: Mapped[datetime] = mapped_column(
DateTime(timezone=True), server_default=func.now(), nullable=False
)

View File

@@ -264,7 +264,7 @@ async def create_comment(
):
await _assert_song_membership(song_id, current_member.id, session)
repo = CommentRepository(session)
comment = await repo.create(song_id=song_id, author_id=current_member.id, body=data.body)
comment = await repo.create(song_id=song_id, author_id=current_member.id, body=data.body, timestamp=data.timestamp)
comment = await repo.get_with_author(comment.id)
return SongCommentRead.from_model(comment)

View File

@@ -8,6 +8,7 @@ from pydantic import BaseModel, ConfigDict
class SongCommentCreate(BaseModel):
body: str
timestamp: float | None = None
class SongCommentRead(BaseModel):
@@ -18,6 +19,7 @@ class SongCommentRead(BaseModel):
body: str
author_id: uuid.UUID
author_name: str
timestamp: float | None
created_at: datetime
@classmethod
@@ -28,5 +30,6 @@ class SongCommentRead(BaseModel):
body=getattr(c, "body"),
author_id=getattr(c, "author_id"),
author_name=getattr(getattr(c, "author"), "display_name"),
timestamp=getattr(c, "timestamp"),
created_at=getattr(c, "created_at"),
)