MCPcopy Index your code
hub / github.com/CodebuffAI/codebuff / fetchRepresentativeRows

Function fetchRepresentativeRows

scripts/export-deepseek-session-traces.ts:377–402  ·  view source on GitHub ↗
(args: Args, messageIds: string[])

Source from the content-addressed store, hash-verified

375}
376
377async function fetchRepresentativeRows(args: Args, messageIds: string[]) {
378 if (messageIds.length === 0) return new Map<string, SessionRow>()
379
380 const query = `
381 SELECT
382 id,
383 finished_at,
384 JSON_VALUE(request, '$.codebuff_metadata.run_id') AS run_id,
385 ARRAY_LENGTH(JSON_QUERY_ARRAY(request, '$.messages')) AS message_count,
386 request AS request_json,
387 response,
388 reasoning_text
389 FROM \`${args.dataset}.message\`
390 WHERE id IN UNNEST(@messageIds)
391 AND JSON_VALUE(request, '$.codebuff_metadata.cost_mode') = 'free'
392 AND JSON_QUERY_ARRAY(request, '$.messages') IS NOT NULL
393 AND COALESCE(JSON_VALUE(request, '$.messages_omitted'), 'false') != 'true'
394 `
395
396 const [rows] = await new BigQuery().query({
397 query,
398 params: { messageIds },
399 })
400
401 return new Map((rows as SessionRow[]).map((row) => [row.id, row]))
402}
403
404function buildTrace(
405 candidate: CandidateRow,

Callers 1

mainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected