Skip to content

insights: new live preview that supports search insights and multiple series

Administrator requested to merge cw/more-live-preview into main

Created by: chwarwick

New live preview that supports both search and capture group insights, also allows for multiple series to be previewed at once. This will allow the UI code to remove it live preview and use the api instead.

resolves #34290 (closed)

example input:

{
  "input": {
    "repositoryScope": {
      "repositories": ["github.com/sourcegraph/sourcegraph"]
    },
    "timeScope": {
      "stepInterval": {
        "unit": "MONTH",
        "value": 1
      }
    },
    "series": [
      {
        "query": "TODO archived:no fork:no",
        "label": "TODO",
        "generatedFromCaptureGroups": false
      },
      {
        "query": "FIXME archived:no fork:no",
        "label": "FIXME",
        "generatedFromCaptureGroups": false
      }
    ]
  }
}

Test plan

Manually verified existing live preview for capture groups worked

Manually executed requests to validate new insightsLivePreview

query GetPreview($input: SearchInsightPreviewInput!) {
  searchInsightPreview(input: $input) {
    points {
      dateTime
      value
      __typename
    }
    label
    __typename
  }
}

Multiple Series Input

{
  "input": {
    "repositoryScope": {
      "repositories": ["github.com/sourcegraph/sourcegraph"]
    },
    "timeScope": {
      "stepInterval": {
        "unit": "MONTH",
        "value": 1
      }
    },
    "series": [
      {
        "query": "TODO archived:no fork:no",
        "label": "TODO",
        "generatedFromCaptureGroups": false
      },
      {
        "query": "FIXME archived:no fork:no",
        "label": "FIXME",
        "generatedFromCaptureGroups": false
      }
    ]
  }
}
response
    {
      "data": {
        "insightLivePreview": [
          {
            "points": [
              {
                "dateTime": "2021-11-06T00:00:00Z",
                "value": 714,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2021-12-06T00:00:00Z",
                "value": 734,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-01-06T00:00:00Z",
                "value": 740,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-02-06T00:00:00Z",
                "value": 789,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-03-06T00:00:00Z",
                "value": 844,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-04-06T00:00:00Z",
                "value": 837,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-05-06T00:00:00Z",
                "value": 860,
                "__typename": "InsightDataPoint"
              }
            ],
            "label": "TODO",
            "__typename": "SearchInsightLivePreviewSeries"
          },
          {
            "points": [
              {
                "dateTime": "2021-11-06T00:00:00Z",
                "value": 5,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2021-12-06T00:00:00Z",
                "value": 9,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-01-06T00:00:00Z",
                "value": 9,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-02-06T00:00:00Z",
                "value": 12,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-03-06T00:00:00Z",
                "value": 13,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-04-06T00:00:00Z",
                "value": 14,
                "__typename": "InsightDataPoint"
              },
              {
                "dateTime": "2022-05-06T00:00:00Z",
                "value": 14,
                "__typename": "InsightDataPoint"
              }
            ],
            "label": "FIXME",
            "__typename": "SearchInsightLivePreviewSeries"
          }
        ]
      }
    }

Capture Group Input

{
  "input": {
    "repositoryScope": {
      "repositories": ["github.com/sourcegraph/sourcegraph"]
    },
    "timeScope": {
      "stepInterval": {
        "unit": "MONTH",
        "value": 1
      }
    },
    "series": [
      {
        "query": "patterntype:regexp FROM\\s+alpine:([\\d\\.]+) file:Dockerfile",
        "label": "Apline Version",
        "generatedFromCaptureGroups": true
      }
    ]
  }
}
response
{
  "data": {
    "insightLivePreview": [
      {
        "points": [
          {
            "dateTime": "2021-11-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2021-12-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-01-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-02-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-03-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-04-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-05-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          }
        ],
        "label": "3.",
        "__typename": "SearchInsightLivePreviewSeries"
      },
      {
        "points": [
          {
            "dateTime": "2021-11-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2021-12-06T20:12:27Z",
            "value": 2,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-01-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-02-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-03-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-04-06T20:12:27Z",
            "value": 3,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-05-06T20:12:27Z",
            "value": 2,
            "__typename": "InsightDataPoint"
          }
        ],
        "label": "3.12",
        "__typename": "SearchInsightLivePreviewSeries"
      },
      {
        "points": [
          {
            "dateTime": "2021-11-06T20:12:27Z",
            "value": 0,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2021-12-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-01-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-02-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-03-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-04-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-05-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          }
        ],
        "label": "3.14",
        "__typename": "SearchInsightLivePreviewSeries"
      },
      {
        "points": [
          {
            "dateTime": "2021-11-06T20:12:27Z",
            "value": 0,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2021-12-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-01-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-02-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-03-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-04-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          },
          {
            "dateTime": "2022-05-06T20:12:27Z",
            "value": 1,
            "__typename": "InsightDataPoint"
          }
        ],
        "label": "3.15",
        "__typename": "SearchInsightLivePreviewSeries"
      }
    ]
  }
}

Merge request reports

Loading