#import TestFragment from "../fragments/test.graphql"

query RunStatus($runId: String!) {
  run(runId: $runId) {
    status
  }
}

query PullRun($runId: String!) {
  run(runId: $runId) {
    qaSet {
      id
    }
    runId
    passPercentage
    status
    textSummary
    timestamp
    completedAt
    archived
    name
    typedParameters {
      evalModel
      maximumThreads
      runGoldenEval
      runConfidenceEvaluation
      heavyweightFactor
      createTextSummary
      modelUnderTest
      temperature
      maxOutputTokens
      systemPrompt
      newLineStopOption
      customParameters
    }
    passRate {
      value
      error
    }
    successRate {
      value
      error
    }
    testSuite {
      id
      title
    }
    project {
      slug
    }
  }
}

query PullTestResultsWithCount($runId: String!, $offset: Int, $limit: Int) {
  testResultsWithCount(
    runId: $runId
    filterOptions: { offset: $offset, limit: $limit }
  ) {
    testResults {
      id
      llmOutput
      passPercentage
      passPercentageWithWeight
      resultJson
      qaPair {
        context
        outputContext
        errorMessage
      }
      test {
        ...TestFragment
      }
      metadata
    }
    count
  }
}

query ListRuns(
  $archived: Boolean
  $suiteId: String
  $projectId: String
  $limit: Int
  $offset: Int
  $search: String
) {
  runsWithCount(
    filterOptions: {
      archived: $archived
      suiteId: $suiteId
      projectId: $projectId
      limit: $limit
      offset: $offset
      sortBy: STARTED_AT
      search: $search
    }
  ) {
    runResults {
      runId
      passPercentage
      passRate {
        value
        error
      }
      successRate {
        value
        error
      }
      name
      status
      textSummary
      timestamp
      completedAt
      archived
      typedParameters {
        evalModel
        maximumThreads
        runGoldenEval
        runConfidenceEvaluation
        heavyweightFactor
        createTextSummary
        modelUnderTest
        temperature
        maxOutputTokens
        systemPrompt
        newLineStopOption
      }
      testSuite {
        title
      }
    }
  }
}
