insights: Generate compute insights for live preview
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:
-
The
withDefaults
function in the query builder removed thecontent:
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
-
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
}
}