From a15a63bc8d98b6b6b357162a033fda4742f98728 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 13 Dec 2023 15:42:17 +0100 Subject: [PATCH 1/2] server: add reviewed field in transcript --- .../versions/b9348748bbbc_reviewed.py | 32 +++++++++++++++++++ server/reflector/db/transcripts.py | 5 +++ server/tests/test_transcripts.py | 26 +++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 server/migrations/versions/b9348748bbbc_reviewed.py diff --git a/server/migrations/versions/b9348748bbbc_reviewed.py b/server/migrations/versions/b9348748bbbc_reviewed.py new file mode 100644 index 00000000..285d94b6 --- /dev/null +++ b/server/migrations/versions/b9348748bbbc_reviewed.py @@ -0,0 +1,32 @@ +"""reviewed + +Revision ID: b9348748bbbc +Revises: 125031f7cb78 +Create Date: 2023-12-13 15:37:51.303970 + +""" +from typing import Sequence, Union + +from alembic import op +import sqlalchemy as sa +from sqlalchemy.dialects import sqlite + +# revision identifiers, used by Alembic. +revision: str = 'b9348748bbbc' +down_revision: Union[str, None] = '125031f7cb78' +branch_labels: Union[str, Sequence[str], None] = None +depends_on: Union[str, Sequence[str], None] = None + + +def upgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('transcript', sa.Column('reviewed', sa.Boolean(), server_default=sa.text('0'), nullable=False)) + op.drop_column('transcript', 'diarization') + # ### end Alembic commands ### + + +def downgrade() -> None: + # ### commands auto generated by Alembic - please adjust! ### + op.add_column('transcript', sa.Column('diarization', sqlite.JSON(), nullable=True)) + op.drop_column('transcript', 'reviewed') + # ### end Alembic commands ### diff --git a/server/reflector/db/transcripts.py b/server/reflector/db/transcripts.py index 779d6137..423f8af6 100644 --- a/server/reflector/db/transcripts.py +++ b/server/reflector/db/transcripts.py @@ -12,6 +12,7 @@ from reflector.db import database, metadata from reflector.processors.types import Word as ProcessorWord from reflector.settings import settings from reflector.storage import Storage +from sqlalchemy.sql import false transcripts = sqlalchemy.Table( "transcript", @@ -30,6 +31,9 @@ transcripts = sqlalchemy.Table( sqlalchemy.Column("participants", sqlalchemy.JSON), sqlalchemy.Column("source_language", sqlalchemy.String, nullable=True), sqlalchemy.Column("target_language", sqlalchemy.String, nullable=True), + sqlalchemy.Column( + "reviewed", sqlalchemy.Boolean, nullable=False, server_default=false() + ), sqlalchemy.Column( "audio_location", sqlalchemy.String, @@ -138,6 +142,7 @@ class Transcript(BaseModel): target_language: str = "en" share_mode: Literal["private", "semi-private", "public"] = "private" audio_location: str = "local" + reviewed: bool = False def add_event(self, event: str, data: BaseModel) -> TranscriptEvent: ev = TranscriptEvent(event=event, data=data.model_dump()) diff --git a/server/tests/test_transcripts.py b/server/tests/test_transcripts.py index 800d7a5c..c708d57e 100644 --- a/server/tests/test_transcripts.py +++ b/server/tests/test_transcripts.py @@ -196,3 +196,29 @@ async def test_transcript_delete(): response = await ac.get(f"/transcripts/{tid}") assert response.status_code == 404 + + +@pytest.mark.asyncio +async def test_transcript_mark_reviewed(): + from reflector.app import app + + async with AsyncClient(app=app, base_url="http://test/v1") as ac: + response = await ac.post("/transcripts", json={"name": "test"}) + assert response.status_code == 200 + assert response.json()["name"] == "test" + assert response.json()["reviewed"] is False + + tid = response.json()["id"] + + response = await ac.get(f"/transcripts/{tid}") + assert response.status_code == 200 + assert response.json()["name"] == "test" + assert response.json()["reviewed"] is False + + response = await ac.patch(f"/transcripts/{tid}", json={"reviewed": True}) + assert response.status_code == 200 + assert response.json()["reviewed"] is True + + response = await ac.get(f"/transcripts/{tid}") + assert response.status_code == 200 + assert response.json()["reviewed"] is True From f0a217a4dc6dc11c24c2806ca1359345dd803143 Mon Sep 17 00:00:00 2001 From: Mathieu Virbel Date: Wed, 13 Dec 2023 15:44:06 +0100 Subject: [PATCH 2/2] www: fix mockup data --- www/app/[domain]/transcripts/useWebSockets.ts | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/www/app/[domain]/transcripts/useWebSockets.ts b/www/app/[domain]/transcripts/useWebSockets.ts index 1e59781c..26b69c05 100644 --- a/www/app/[domain]/transcripts/useWebSockets.ts +++ b/www/app/[domain]/transcripts/useWebSockets.ts @@ -62,6 +62,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "1", timestamp: 10, + duration: 10, summary: "This is test topic 1", title: "Topic 1: Introduction to Quantum Mechanics", transcript: @@ -103,6 +104,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "2", timestamp: 20, + duration: 10, summary: "This is test topic 2", title: "Topic 2: Machine Learning Algorithms", transcript: @@ -123,6 +125,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "3", timestamp: 30, + duration: 10, summary: "This is test topic 3", title: "Topic 3: Mental Health Awareness", transcript: "Ways to improve mental health and reduce stigma.", @@ -142,6 +145,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "4", timestamp: 40, + duration: 10, summary: "This is test topic 4", title: "Topic 4: Basics of Productivity", transcript: "Tips and tricks to increase daily productivity.", @@ -161,6 +165,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "5", timestamp: 50, + duration: 10, summary: "This is test topic 5", title: "Topic 5: Future of Aviation", transcript: @@ -190,6 +195,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "1", timestamp: 10, + duration: 10, summary: "This is test topic 1", title: "Topic 1: Introduction to Quantum Mechanics, a brief overview of quantum mechanics and its principles.", @@ -211,6 +217,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "2", timestamp: 20, + duration: 10, summary: "This is test topic 2", title: "Topic 2: Machine Learning Algorithms, understanding the different types of machine learning algorithms.", @@ -232,6 +239,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "3", timestamp: 30, + duration: 10, summary: "This is test topic 3", title: "Topic 3: Mental Health Awareness, ways to improve mental health and reduce stigma.", @@ -252,6 +260,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "4", timestamp: 40, + duration: 10, summary: "This is test topic 4", title: "Topic 4: Basics of Productivity, tips and tricks to increase daily productivity.", @@ -272,6 +281,7 @@ export const useWebSockets = (transcriptId: string | null): UseWebSockets => { { id: "5", timestamp: 50, + duration: 10, summary: "This is test topic 5", title: "Topic 5: Future of Aviation, exploring the advancements and possibilities in aviation.",