fix(api): accept fractional progress seconds (R6 S1b code-review round 1)
/code-review high round 1 on S1b — 5 findings, 1 fixed, 4 by-design/deferred: - FIXED: VideoProgressIn / ItemProgressIn position_seconds & duration_seconds typed `int` would 422 a raw float currentTime on the 10s progress checkpoint (the old `int(payload.get(...))` truncated it). Back to `float`, truncated in the handler; +test. The live frontend floors so this was latent, not live. By-design / deferred (no change): the 422 detail-array isn't localized by the FE (filed under R7); PATCH is-not-none (channels/quota, null-safe) vs model_fields_set (nullable-clear) is a deliberate split; missing-field→422 is the point of the epic; me/switch_account's numeric-string coercion is more correct and still session-gated. Gate: ruff clean, pytest 172 green.
This commit is contained in:
@@ -1943,8 +1943,10 @@ def _push_watch(
|
||||
|
||||
|
||||
class ItemProgressIn(BaseModel):
|
||||
position_seconds: int = 0
|
||||
duration_seconds: int = 0
|
||||
# float, truncated in the handler — the player may post a raw currentTime (a float); a plain
|
||||
# `int` field would 422 it on the periodic progress checkpoint (the old `int(...)` truncated).
|
||||
position_seconds: float = 0
|
||||
duration_seconds: float = 0
|
||||
final: bool = False
|
||||
|
||||
|
||||
@@ -1962,8 +1964,8 @@ def item_progress(
|
||||
debounces the Plex resume push: we mirror the settled position to Plex only on a final flush, so
|
||||
a single watch doesn't spray `/:/timeline` calls at the server every 10 seconds."""
|
||||
it = _item_or_404(db, rating_key)
|
||||
position = max(0, body.position_seconds)
|
||||
duration = body.duration_seconds
|
||||
position = max(0, int(body.position_seconds))
|
||||
duration = int(body.duration_seconds)
|
||||
final = body.final
|
||||
now = datetime.now(timezone.utc)
|
||||
st = db.query(PlexState).filter_by(user_id=user.id, item_id=it.id).first()
|
||||
|
||||
Reference in New Issue
Block a user