Sprint 002: Ingest duration & view count, FTS search, infinite scroll pagination, and transcript accordion
Deploy t-youtube / Build & Deploy (push) Failing after 1s

This commit is contained in:
Gan, Jimmy
2026-07-11 13:16:59 +08:00
parent 623dff149c
commit 022b024603
6 changed files with 207 additions and 91 deletions
+10 -9
View File
@@ -107,11 +107,12 @@ async def root():
async def get_videos(
status: Optional[str] = "pending",
limit: int = 50,
offset: int = 0,
channel: Optional[str] = None,
search: Optional[str] = None,
db: aiosqlite.Connection = Depends(get_db)
):
"""Get videos with optional search filter."""
"""Get videos with optional search filter and pagination."""
if search and len(search) >= 2:
# Use search endpoint logic
q = search.replace('"', '\\"')
@@ -123,15 +124,15 @@ async def get_videos(
if channel:
base_query += " AND v.channel_name = ?"
params.append(channel)
base_query += " ORDER BY rank LIMIT ?"
params.append(limit)
base_query += " ORDER BY rank LIMIT ? OFFSET ?"
params.extend([limit, offset])
else:
if channel:
query = "SELECT * FROM videos WHERE status = ? AND channel_name = ? ORDER BY publish_date DESC, created_at DESC LIMIT ?"
cursor = await db.execute(query, (status, channel, limit))
query = "SELECT * FROM videos WHERE status = ? AND channel_name = ? ORDER BY publish_date DESC, created_at DESC LIMIT ? OFFSET ?"
cursor = await db.execute(query, (status, channel, limit, offset))
else:
query = "SELECT * FROM videos WHERE status = ? ORDER BY publish_date DESC, created_at DESC LIMIT ?"
cursor = await db.execute(query, (status, limit))
query = "SELECT * FROM videos WHERE status = ? ORDER BY publish_date DESC, created_at DESC LIMIT ? OFFSET ?"
cursor = await db.execute(query, (status, limit, offset))
rows = await cursor.fetchall()
return [dict(row) for row in rows]
@@ -147,8 +148,8 @@ async def get_videos(
if channel:
like_query += " AND channel_name = ?"
params.append(channel)
like_query += " ORDER BY publish_date DESC LIMIT ?"
params.append(limit)
like_query += " ORDER BY publish_date DESC LIMIT ? OFFSET ?"
params.extend([limit, offset])
cursor = await db.execute(like_query, params)
rows = await cursor.fetchall()