fix: dedupe player-edit route + strip embedding blob from JSON
Follow-up to the /players build:
- the new POST /player/{id} collided with the existing PATCH route (F811); fold
the name→named-flip into the existing PATCH and point the UI at it.
- villain_recall / update_player returned the raw row including
descriptor_embedding (bytes) → PydanticSerializationError on the API. Strip it.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+10
-13
@@ -212,9 +212,17 @@ def create_app() -> FastAPI:
|
||||
|
||||
@app.patch("/player/{player_id}")
|
||||
async def player_update(player_id: int, request: Request) -> dict:
|
||||
"""Edit a player's dossier (rename, fix tendencies)."""
|
||||
"""Edit a player's dossier (rename, fix tendencies). Setting `name` on a
|
||||
nameless (descriptor) villain promotes it to a real handle (named=1)."""
|
||||
body = await request.json()
|
||||
p = await asyncio.to_thread(lambda: poker.update_player(player_id, **body))
|
||||
|
||||
def _apply():
|
||||
if body.get("name"):
|
||||
poker.name_villain(player_id, body["name"])
|
||||
rest = {k: v for k, v in body.items() if k != "name"}
|
||||
return poker.update_player(player_id, **rest) if rest else poker.villain_recall(player_id)
|
||||
|
||||
p = await asyncio.to_thread(_apply)
|
||||
logbus.log("info", "player edited", id=player_id, fields=list(body))
|
||||
return {"ok": p is not None, "player": p}
|
||||
|
||||
@@ -450,17 +458,6 @@ def create_app() -> FastAPI:
|
||||
async def player_data(player_id: int) -> dict:
|
||||
return poker.villain_recall(player_id) or {}
|
||||
|
||||
@app.post("/player/{player_id}")
|
||||
async def player_update(player_id: int, request: Request) -> dict:
|
||||
body = await request.json()
|
||||
fields = {k: body[k] for k in ("name", "venue", "category", "tendencies",
|
||||
"adjustment", "description") if body.get(k) is not None}
|
||||
if body.get("name"): # naming via the browser flips it to a real handle
|
||||
poker.name_villain(player_id, body["name"])
|
||||
fields.pop("name", None)
|
||||
row = poker.update_player(player_id, **fields) if fields else None
|
||||
return {"ok": True, "player": row}
|
||||
|
||||
@app.post("/identity/{task_id}/resolve")
|
||||
async def identity_resolve(task_id: int, request: Request) -> dict:
|
||||
body = await request.json()
|
||||
|
||||
Reference in New Issue
Block a user