Skip to content

insights: Generate compute insights for live preview

Administrator requested to merge insights/preview-compute into main

Created by: CristinaBirkel

Closes https://github.com/sourcegraph/sourcegraph/issues/37867

Description

This PR adds groupBy to the live preview endpoints to allow compute insights to show a live preview. A couple things to note:

  1. The withDefaults function in the query builder removed the content: portion from the query so I bypassed it for now. I'm not sure we need it anyway? Regardless though there's a ticket for this here: https://github.com/sourcegraph/sourcegraph/issues/37173. I added a new method to build the query for this: SingleRepoQueryIndexed

  2. I did a quick v1 sort/limit just so that we get something stable here. We can decide how to prioritize the same sort/limit options we have for other insights. It isn't exactly plug and play because of the different types of resolvers. I'll create a ticket for it. https://github.com/sourcegraph/sourcegraph/issues/38309

Test plan

Here's a query you can use to see the live preview working.

query {
  searchInsightPreview(input: {
    repositoryScope:{
	repositories: ["github.com/sourcegraph/sourcegraph", "github.com/sourcegraph-testing/etcd", "github.com/sourcegraph-testing/tidb"]
    },
    timeScope: {
	stepInterval:{
        unit: WEEK,
        value: 1
      }
    },
    series: {
      query:"((.|)*) type:commit",
      label:"hi",
      generatedFromCaptureGroups:false,
      groupBy: AUTHOR
    }
  }
  ) {
    points { dateTime, value }, label
  }
}

Merge request reports

Loading