( userId: string, deps: SessionDeps, row: InternalSessionRow, )
| 289 | } |
| 290 | |
| 291 | async function viewForRow( |
| 292 | userId: string, |
| 293 | deps: SessionDeps, |
| 294 | row: InternalSessionRow, |
| 295 | ): Promise<SessionStateResponse | null> { |
| 296 | const [position, depthsByModel] = |
| 297 | row.status === 'queued' |
| 298 | ? await Promise.all([ |
| 299 | deps.queuePositionFor({ |
| 300 | userId, |
| 301 | model: row.model, |
| 302 | queuedAt: row.queued_at, |
| 303 | }), |
| 304 | deps.queueDepthsByModel(), |
| 305 | ]) |
| 306 | : [0, {}] |
| 307 | return toSessionStateResponse({ |
| 308 | row, |
| 309 | position, |
| 310 | queueDepthByModel: depthsByModel, |
| 311 | graceMs: deps.graceMs, |
| 312 | now: nowOf(deps), |
| 313 | }) |
| 314 | } |
| 315 | |
| 316 | export type RequestSessionResult = |
| 317 | | SessionStateResponse |
no test coverage detected