-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
155 additions
and
11 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
from tests.factories.transcript import TranscriptFactory |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
from factory import Sequence | ||
from factory.alchemy import SQLAlchemyModelFactory | ||
|
||
from via.models import Transcript | ||
|
||
|
||
class TranscriptFactory(SQLAlchemyModelFactory): | ||
class Meta: | ||
model = Transcript | ||
|
||
video_id = Sequence(lambda n: f"video_id_{n}") | ||
transcript_id = Sequence(lambda n: f"transcript_id_{n}") | ||
transcript = [ | ||
{ | ||
"text": "[Music]", | ||
"start": 0.0, | ||
"duration": 7.52, | ||
}, | ||
{ | ||
"text": "how many of you remember the first time", | ||
"start": 5.6, | ||
"duration": 4.72, | ||
}, | ||
{ | ||
"text": "you saw a playstation 1 game if you were", | ||
"start": 7.52, | ||
"duration": 4.72, | ||
}, | ||
] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
from via.models.transcript import Transcript | ||
|
||
|
||
def includeme(_config): # pragma: no cover | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
from datetime import datetime | ||
|
||
from sqlalchemy import func | ||
from sqlalchemy.orm import Mapped, MappedAsDataclass, mapped_column | ||
|
||
|
||
class CreatedUpdatedMixin(MappedAsDataclass): | ||
created: Mapped[datetime] = mapped_column( | ||
init=False, | ||
repr=False, | ||
server_default=func.now(), # pylint:disable=not-callable | ||
sort_order=-10, | ||
) | ||
updated: Mapped[datetime] = mapped_column( | ||
init=False, | ||
repr=False, | ||
server_default=func.now(), # pylint:disable=not-callable | ||
onupdate=func.now(), # pylint:disable=not-callable | ||
sort_order=-10, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
from sqlalchemy import UniqueConstraint | ||
from sqlalchemy.dialects.postgresql import JSONB | ||
from sqlalchemy.orm import Mapped, mapped_column | ||
|
||
from via.db import Base | ||
from via.models._mixins import CreatedUpdatedMixin | ||
|
||
|
||
class Transcript(CreatedUpdatedMixin, Base): | ||
__tablename__ = "transcript" | ||
__table_args__ = (UniqueConstraint("video_id", "transcript_id"),) | ||
|
||
id: Mapped[int] = mapped_column(primary_key=True, autoincrement=True, init=False) | ||
video_id: Mapped[str] | ||
transcript_id: Mapped[str] | ||
transcript: Mapped[list] = mapped_column(JSONB, repr=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters