Skip to content

Commit 76538e2

Browse files
authored
Merge pull request #11 from KillrVideo/feat/explore-videos-pagination
feat: enable Explore Videos via full pagination on /videos/latest
2 parents cc817fb + 1eb67c0 commit 76538e2

2 files changed

Lines changed: 80 additions & 5 deletions

File tree

app/services/video_service.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -542,15 +542,12 @@ async def list_latest_videos(
542542
page_size: int,
543543
db_table: Optional[AstraDBCollection] = None,
544544
) -> Tuple[List[VideoSummary], int]:
545-
"""Return the newest *three* videos across all days for the home page row."""
546-
547-
# We only need a single row of 3 videos on the UI – cap the page size.
548-
effective_size = min(page_size, 3)
545+
"""Return the newest videos across all days, sorted by submission date descending."""
549546

550547
return await list_videos_with_query(
551548
{},
552549
page,
553-
effective_size,
550+
page_size,
554551
sort_options={"added_date": -1},
555552
db_table=db_table,
556553
source_table_name=VIDEOS_TABLE_NAME,

docs/explore-videos-frontend.md

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
# Explore Videos — Frontend Integration Guide
2+
3+
## Endpoint
4+
5+
```
6+
GET /api/v1/videos/latest
7+
```
8+
9+
No authentication required (public endpoint).
10+
11+
## Query Parameters
12+
13+
| Parameter | Type | Default | Range | Description |
14+
|------------|------|---------|--------|----------------------|
15+
| `page` | int | 1 | >= 1 | Page number |
16+
| `pageSize` | int | 10 | 1–100 | Items per page |
17+
18+
## Example Request
19+
20+
```
21+
GET /api/v1/videos/latest?page=1&pageSize=12
22+
```
23+
24+
## Response Shape
25+
26+
```json
27+
{
28+
"data": [
29+
{
30+
"videoId": "uuid",
31+
"title": "Video Title",
32+
"thumbnailUrl": "https://i.ytimg.com/vi/.../hqdefault.jpg",
33+
"userId": "uuid",
34+
"submittedAt": "2025-12-01T14:30:00Z",
35+
"content_rating": null,
36+
"category": null
37+
}
38+
],
39+
"pagination": {
40+
"currentPage": 1,
41+
"pageSize": 12,
42+
"totalItems": 47,
43+
"totalPages": 4
44+
}
45+
}
46+
```
47+
48+
## Key Fields in Each Video
49+
50+
| Field | Type | Notes |
51+
|-----------------|-------------|------------------------------------------|
52+
| `videoId` | UUID string | Use for routing to `/videos/{videoId}` |
53+
| `title` | string | Display name |
54+
| `thumbnailUrl` | URL or null | YouTube thumbnail; use placeholder if null |
55+
| `userId` | UUID string | Uploader's user ID |
56+
| `submittedAt` | ISO 8601 | When the video was added |
57+
| `content_rating`| string/null | Optional content rating |
58+
| `category` | string/null | Optional category |
59+
60+
## Pagination
61+
62+
Use `pagination.totalPages` to render page controls. To fetch the next page:
63+
64+
```
65+
GET /api/v1/videos/latest?page=2&pageSize=12
66+
```
67+
68+
## Suggested UX
69+
70+
- Default to `pageSize=12` (works well in 3- or 4-column grids)
71+
- Show video cards with thumbnail, title, and submission date
72+
- Link each card to the video detail page using `videoId`
73+
- Use `totalItems` to show "Showing X of Y videos"
74+
- Consider infinite scroll or "Load More" using incrementing `page` values
75+
76+
## Sort Order
77+
78+
Videos are sorted **newest first** (by `submittedAt` descending). There is currently no parameter to change sort order.

0 commit comments

Comments
 (0)