Spaces:
Running
Running
sghorbal commited on
Commit ·
11e87b3
1
Parent(s): 8c0f987
expose the reference data through api
Browse files- src/main.py +38 -0
src/main.py
CHANGED
|
@@ -236,6 +236,44 @@ async def list_tournament_names(
|
|
| 236 |
|
| 237 |
return tournaments
|
| 238 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
|
| 240 |
class ListPlayersInput(BaseModel):
|
| 241 |
ids: List[int] = Field(
|
|
|
|
| 236 |
|
| 237 |
return tournaments
|
| 238 |
|
| 239 |
+
@app.get("/references/courts", tags=["reference"], description="List all the courts")
|
| 240 |
+
async def list_courts(
|
| 241 |
+
session: Annotated[Session, Depends(get_session)]
|
| 242 |
+
):
|
| 243 |
+
"""
|
| 244 |
+
List all the courts
|
| 245 |
+
"""
|
| 246 |
+
courts = session.execute(text("SELECT name FROM data.ref_court_m_view")).all()
|
| 247 |
+
|
| 248 |
+
courts = [court[0] for court in courts]
|
| 249 |
+
|
| 250 |
+
return courts
|
| 251 |
+
|
| 252 |
+
@app.get("/references/surfaces", tags=["reference"], description="List all the surfaces")
|
| 253 |
+
async def list_surfaces(
|
| 254 |
+
session: Annotated[Session, Depends(get_session)]
|
| 255 |
+
):
|
| 256 |
+
"""
|
| 257 |
+
List all the surfaces
|
| 258 |
+
"""
|
| 259 |
+
surfaces = session.execute(text("SELECT name FROM data.ref_surface_m_view")).all()
|
| 260 |
+
|
| 261 |
+
surfaces = [surface[0] for surface in surfaces]
|
| 262 |
+
|
| 263 |
+
return surfaces
|
| 264 |
+
|
| 265 |
+
@app.get("/references/series", tags=["reference"], description="List all the series")
|
| 266 |
+
async def list_series(
|
| 267 |
+
session: Annotated[Session, Depends(get_session)]
|
| 268 |
+
):
|
| 269 |
+
"""
|
| 270 |
+
List all the series
|
| 271 |
+
"""
|
| 272 |
+
series = session.execute(text("SELECT name FROM data.ref_series_m_view")).all()
|
| 273 |
+
|
| 274 |
+
series = [serie[0] for serie in series]
|
| 275 |
+
|
| 276 |
+
return series
|
| 277 |
|
| 278 |
class ListPlayersInput(BaseModel):
|
| 279 |
ids: List[int] = Field(
|