Skip to content

insights: fix bug where JIT capture groups return values only for 1 repo

Administrator requested to merge insights/fix-capture-group-jit-bug into main

Created by: leonore

closes #35602 (closed), see the issue for more details + findings.

When collating the data together for all repos we were re-initialising the pivoted value at each timestamp on each iteration, essentially only keeping the data for the last repo search.

Test plan

Tested manually by creating an insight and checking correctness, and checking the values returned by GetInsightView on the graphQL API.

  1. Create a JIT capture group insight: https://sourcegraph.test:3443/insights/create/capture-group?dashboardId=all
  2. The query I picked was var\(--(color-bg-\d)\) for ease of correctness checking.
  3. Add these repos: github.com/sourcegraph/about, github.com/sourcegraph/sourcegraph, github.com/sourcegraph-testing/demo-sourcegraph (add them in dev-private/external-services-config.json if required
  4. Compare values to search queries
image image

If you run this locally you can see that for the individual queries and individual repos they are correct as well.

For GraphQL, the following query:

query GetInsightView($id: ID, $filters: InsightViewFiltersInput) {
  insightViews(id: $id, filters: $filters) {
    nodes {
      ...InsightDataNode
      __typename
    }
    __typename
  }
}

fragment InsightDataNode on InsightView {
  id
  dataSeries {
    ...InsightDataSeries
    __typename
  }
  __typename
}

fragment InsightDataSeries on InsightsSeries {
  seriesId
  label
  points {
    dateTime
    value
    __typename
  }
  status {
    backfillQueuedAt
    completedJobs
    pendingJobs
    failedJobs
    __typename
  }
  __typename
}

with the id of the insight you have just created, returns correct values as well.

Merge request reports

Loading