(streamId: string, userId?: string)
| 167 | // Un-instrumented: called from a 4 Hz resume poll; per-call spans |
| 168 | // swamped traces. Use Prom histograms if latency visibility is needed. |
| 169 | export async function getLatestRunForStream(streamId: string, userId?: string) { |
| 170 | const conditions = userId |
| 171 | ? and(eq(copilotRuns.streamId, streamId), eq(copilotRuns.userId, userId)) |
| 172 | : eq(copilotRuns.streamId, streamId) |
| 173 | const [run] = await db |
| 174 | .select() |
| 175 | .from(copilotRuns) |
| 176 | .where(conditions) |
| 177 | .orderBy(desc(copilotRuns.startedAt)) |
| 178 | .limit(1) |
| 179 | return run ?? null |
| 180 | } |
| 181 | |
| 182 | export async function getRunSegment(runId: string) { |
| 183 | return withDbSpan( |
no test coverage detected