|
25 | 25 | from ..dependencies.authentication import get_current_user_id, get_product_name |
26 | 26 | from ..dependencies.services import get_api_client |
27 | 27 | from ..dependencies.webserver_http import AuthSession, get_webserver_session |
28 | | -from ._common import API_SERVER_DEV_FEATURES_ENABLED |
29 | 28 | from ._constants import ( |
30 | 29 | FMSG_CHANGELOG_NEW_IN_VERSION, |
31 | 30 | FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT, |
@@ -127,7 +126,7 @@ async def get_solvers_page( |
127 | 126 | description=create_route_description( |
128 | 127 | base="Lists all released solvers (not just latest version)", |
129 | 128 | deprecated=True, |
130 | | - alternative="GET /v0/solvers/releases/page", |
| 129 | + alternative="GET /v0/solvers/{solver_key}/releases/page", |
131 | 130 | changelog=[ |
132 | 131 | FMSG_CHANGELOG_NEW_IN_VERSION.format("0.5.0", ""), |
133 | 132 | FMSG_CHANGELOG_REMOVED_IN_VERSION_FORMAT.format( |
@@ -176,19 +175,6 @@ async def list_solvers_releases( |
176 | 175 | return sorted(all_solvers, key=attrgetter("id", "pep404_version")) |
177 | 176 |
|
178 | 177 |
|
179 | | -@router.get( |
180 | | - "/releases/page", |
181 | | - response_model=Page[Solver], |
182 | | - include_in_schema=API_SERVER_DEV_FEATURES_ENABLED, |
183 | | - status_code=status.HTTP_501_NOT_IMPLEMENTED, |
184 | | -) |
185 | | -async def get_solvers_releases_page( |
186 | | - page_params: Annotated[PaginationParams, Depends()], |
187 | | -): |
188 | | - msg = f"list solvers releases with pagination={page_params!r}" |
189 | | - raise NotImplementedError(msg) |
190 | | - |
191 | | - |
192 | 178 | @router.get( |
193 | 179 | "/{solver_key:path}/latest", |
194 | 180 | response_model=Solver, |
@@ -257,15 +243,28 @@ async def list_solver_releases( |
257 | 243 | @router.get( |
258 | 244 | "/{solver_key:path}/releases/page", |
259 | 245 | response_model=Page[Solver], |
260 | | - include_in_schema=API_SERVER_DEV_FEATURES_ENABLED, |
261 | | - status_code=status.HTTP_501_NOT_IMPLEMENTED, |
262 | 246 | ) |
263 | 247 | async def get_solver_releases_page( |
264 | 248 | solver_key: SolverKeyId, |
265 | 249 | page_params: Annotated[PaginationParams, Depends()], |
| 250 | + user_id: Annotated[int, Depends(get_current_user_id)], |
| 251 | + product_name: Annotated[str, Depends(get_product_name)], |
| 252 | + solver_service: Annotated[SolverService, Depends(SolverService)], |
266 | 253 | ): |
267 | | - msg = f"list solver {solver_key=} (one) releases with pagination={page_params!r}" |
268 | | - raise NotImplementedError(msg) |
| 254 | + solvers, page_meta = await solver_service.solver_release_history( |
| 255 | + user_id=user_id, |
| 256 | + solver_key=solver_key, |
| 257 | + product_name=product_name, |
| 258 | + offset=page_params.offset, |
| 259 | + limit=page_params.limit, |
| 260 | + ) |
| 261 | + page_params.limit = page_meta.limit |
| 262 | + page_params.offset = page_meta.offset |
| 263 | + return create_page( |
| 264 | + solvers, |
| 265 | + total=len(solvers), |
| 266 | + params=page_params, |
| 267 | + ) |
269 | 268 |
|
270 | 269 |
|
271 | 270 | @router.get( |
|
0 commit comments