Add now-playing and upcoming movie endpoints
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
CI / lint (push) Canceled after 0s
CI / typecheck (push) Canceled after 0s
CI / unit-tests (push) Canceled after 0s
CI / integration-tests (push) Canceled after 0s
CI / container-build (push) Canceled after 0s
CI / dependency-audit (push) Canceled after 0s
Buildable now that release_dates exists: GET /movies/now-playing and /movies/upcoming filter on release_type="theatrical" per region, windowed around today. A movie can carry more than one theatrical-type row in the same region (limited release then wide release both map to "theatrical" per normalizer._RELEASE_TYPE_MAP) -- collapsed to one row per movie via a grouped subquery rather than joining ReleaseDate directly, which would duplicate the movie in the page and inflate the total count. Co-Authored-By: Claude Sonnet 5 <[email protected]>
This commit is contained in:
co-authored by
Claude Sonnet 5
parent
567b4ef068
commit
74ebad379a
@@ -192,6 +192,30 @@ async def build_movie_summaries(
|
||||
return out
|
||||
|
||||
|
||||
async def list_now_playing(
|
||||
session: AsyncSession, *, region: str, page: int, page_size: int
|
||||
) -> MovieListOut:
|
||||
movies, total = await movie_repository.list_now_playing(
|
||||
session, region=region.upper(), limit=page_size, offset=(page - 1) * page_size
|
||||
)
|
||||
results = [await _movie_summary_from_row(session, m) for m in movies]
|
||||
total_pages = (total + page_size - 1) // page_size if total else 0
|
||||
return MovieListOut(
|
||||
page=page, page_size=page_size, total_results=total, total_pages=total_pages, results=results
|
||||
)
|
||||
|
||||
|
||||
async def list_upcoming(session: AsyncSession, *, region: str, page: int, page_size: int) -> MovieListOut:
|
||||
movies, total = await movie_repository.list_upcoming(
|
||||
session, region=region.upper(), limit=page_size, offset=(page - 1) * page_size
|
||||
)
|
||||
results = [await _movie_summary_from_row(session, m) for m in movies]
|
||||
total_pages = (total + page_size - 1) // page_size if total else 0
|
||||
return MovieListOut(
|
||||
page=page, page_size=page_size, total_results=total, total_pages=total_pages, results=results
|
||||
)
|
||||
|
||||
|
||||
async def list_movies(
|
||||
session: AsyncSession,
|
||||
*,
|
||||
|
||||
Reference in New Issue
Block a user