Skip to content
Snippets Groups Projects
Commit 7281ce67 authored by Simon Künzel's avatar Simon Künzel
Browse files

Fix medium db mapper

parent fc812c4e
Branches
No related tags found
No related merge requests found
......@@ -74,9 +74,10 @@ class SourceMedium(DeletableApiObject, Base):
data_notes="Only calculated once this is sorted"
)
)
metadata: Mapped[JsonTypes] = api_mapped(
# metadata is reserved
file_metadata: Mapped[JsonTypes] = api_mapped(
mapped_column(sql.JSON, nullable=True),
ApiDataField(
ApiJsonField(
include_in_data=True,
# See source file sorter for contents
data_notes="Only calculated once this is sorted. There are no guarantees regarding the content"
......@@ -195,8 +196,8 @@ class TargetMedium(DeletableApiObject, Base):
return options
class FileTargetMedium(TargetMedium):
file_path: Mapped[str] = mapped_column(String(collation=STRING_COLLATION), nullable=True, index=True) # TODO move?
class FileMedium(ApiObject):
file_path: Mapped[str] = mapped_column(String(collation=STRING_COLLATION), nullable=True, use_existing_column=True, index=True) # TODO move?
@api_include_in_data(
type_id="string",
......@@ -212,81 +213,80 @@ class FileTargetMedium(TargetMedium):
return f"{self.process_target_id}.{self.id}"
class SingleAudioContainingMedium(TargetMedium):
class SingleAudioContainingMedium(ApiObject):
audio_sample_rate: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True,
help="In Hz"
data_notes="In Hz"
)
)
audio_channel_count: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
class SingleVideoContainingMedium(TargetMedium):
class SingleVideoContainingMedium(ApiObject):
video_vertical_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
video_horizontal_resolution: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
video_frame_rate_numerator: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
video_frame_rate_denominator: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
class PlainVideoTargetMedium(FileTargetMedium, SingleVideoContainingMedium, SingleAudioContainingMedium):
class PlainVideoTargetMedium(TargetMedium, FileMedium, SingleVideoContainingMedium, SingleAudioContainingMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = {
"polymorphic_identity": TargetMediumType.PLAIN_VIDEO
}
duration_sec: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
# TODO check vars not null (except audio)
class PlainAudioTargetMedium(FileTargetMedium, SingleAudioContainingMedium):
class PlainAudioTargetMedium(TargetMedium, FileMedium, SingleAudioContainingMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = {
"polymorphic_identity": TargetMediumType.PLAIN_AUDIO
}
duration_sec: Mapped[int] = api_mapped(
mapped_column(nullable=True),
mapped_column(nullable=True, use_existing_column=True),
ApiIntegerField(
include_in_data=True
)
)
class ThumbnailTargetMedium(FileTargetMedium):
class ThumbnailTargetMedium(FileMedium):
__tablename__ = None # Prevent our own base from adding a table name. This should be a single-table inheritance
__mapper_args__ = {
"polymorphic_identity": TargetMediumType.THUMBNAIL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment