#import TestFragment from "../fragments/test.graphql"
#import { ResultJsonElementTypeFields, MetadataOutputTypeFields } from "../fragments/shared.graphql"

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

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

query PullTestResultsWithCount($runId: String!, $offset: Int, $limit: Int) {
  testResultsWithCount(
    runId: $runId
    filterOptions: { offset: $offset, limit: $limit }
  ) {
    testResults {
      id
      llmOutput
      passPercentage
      passPercentageWithWeight
      resultJson {
        ...ResultJsonElementTypeFields
      }
      qaPair {
        context
        outputContext
        errorMessage
      }
      test {
        ...TestFragment
      }
      metadata {
        ...MetadataOutputTypeFields
      }
    }
    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
      parameters {
        evalModel
        maximumThreads
        runConfidenceEvaluation
        heavyweightFactor
        createTextSummary
        modelUnderTest
        temperature
        maxOutputTokens
        systemPrompt
      }
      testSuite {
        title
      }
    }
  }
}

query UnfinishedTests($runId: String!) {
  unfinishedTests(runId: $runId) {
    unfinishedTests {
      ...TestFragment
    }
    testSuiteSize
  }
}
