feat: Added video_filename field to KeyMomentSummary schema and populat…
- "backend/schemas.py" - "backend/routers/techniques.py" GSD-Task: S03/T01
This commit is contained in:
parent
8dc7097603
commit
769746197c
2 changed files with 8 additions and 3 deletions
|
|
@ -11,7 +11,7 @@ from sqlalchemy.ext.asyncio import AsyncSession
|
||||||
from sqlalchemy.orm import selectinload
|
from sqlalchemy.orm import selectinload
|
||||||
|
|
||||||
from database import get_session
|
from database import get_session
|
||||||
from models import Creator, KeyMoment, RelatedTechniqueLink, TechniquePage
|
from models import Creator, KeyMoment, RelatedTechniqueLink, SourceVideo, TechniquePage
|
||||||
from schemas import (
|
from schemas import (
|
||||||
CreatorInfo,
|
CreatorInfo,
|
||||||
KeyMomentSummary,
|
KeyMomentSummary,
|
||||||
|
|
@ -75,7 +75,7 @@ async def get_technique(
|
||||||
select(TechniquePage)
|
select(TechniquePage)
|
||||||
.where(TechniquePage.slug == slug)
|
.where(TechniquePage.slug == slug)
|
||||||
.options(
|
.options(
|
||||||
selectinload(TechniquePage.key_moments),
|
selectinload(TechniquePage.key_moments).selectinload(KeyMoment.source_video),
|
||||||
selectinload(TechniquePage.creator),
|
selectinload(TechniquePage.creator),
|
||||||
selectinload(TechniquePage.outgoing_links).selectinload(
|
selectinload(TechniquePage.outgoing_links).selectinload(
|
||||||
RelatedTechniqueLink.target_page
|
RelatedTechniqueLink.target_page
|
||||||
|
|
@ -93,7 +93,11 @@ async def get_technique(
|
||||||
|
|
||||||
# Build key moments (ordered by start_time)
|
# Build key moments (ordered by start_time)
|
||||||
key_moments = sorted(page.key_moments, key=lambda km: km.start_time)
|
key_moments = sorted(page.key_moments, key=lambda km: km.start_time)
|
||||||
key_moment_items = [KeyMomentSummary.model_validate(km) for km in key_moments]
|
key_moment_items = []
|
||||||
|
for km in key_moments:
|
||||||
|
item = KeyMomentSummary.model_validate(km)
|
||||||
|
item.video_filename = km.source_video.filename if km.source_video else ""
|
||||||
|
key_moment_items.append(item)
|
||||||
|
|
||||||
# Build creator info
|
# Build creator info
|
||||||
creator_info = None
|
creator_info = None
|
||||||
|
|
|
||||||
|
|
@ -286,6 +286,7 @@ class KeyMomentSummary(BaseModel):
|
||||||
end_time: float
|
end_time: float
|
||||||
content_type: str
|
content_type: str
|
||||||
plugins: list[str] | None = None
|
plugins: list[str] | None = None
|
||||||
|
video_filename: str = ""
|
||||||
|
|
||||||
|
|
||||||
class RelatedLinkItem(BaseModel):
|
class RelatedLinkItem(BaseModel):
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue