Skip to content

Insights: support filtering just in time insights with search contexts embedded query

Administrator requested to merge insights/context-jit into main

Created by: coury-clark

This adds support to filter just-in-time queries based on search contexts, and union them with the standalone regexp values.

Test plan

Adds a variety of unit tests, and tested a variety of include / exclude possibilities locally such as below

query insightview{
  insightViews (id:"aW5zaWdodF92aWV3OiIyN2lLSmJZcTNraWs3UXNWbENJOTczQTVrM2ki", filters:{searchContexts:["@dev/srcall"], excludeRepoRegex:"testing"}) {
    nodes {
      id
      appliedFilters {
        excludeRepoRegex
        includeRepoRegex
      }
      defaultFilters {
        excludeRepoRegex
        includeRepoRegex
      }
      dataSeriesDefinitions {
        ... on SearchInsightDataSeriesDefinition {
          query
        }
      }
      dataSeries {
        label
        points {
          value
          dateTime
        }
      }
    }
  }
}
{
  "data": {
    "insightViews": {
      "nodes": [
        {
          "id": "aW5zaWdodF92aWV3OiIyN2lLSmJZcTNraWs3UXNWbENJOTczQTVrM2ki",
          "appliedFilters": {
            "excludeRepoRegex": "testing",
            "includeRepoRegex": null
          },
          "defaultFilters": {
            "excludeRepoRegex": "",
            "includeRepoRegex": ""
          },
          "dataSeriesDefinitions": [
            {
              "query": "file:go\\.mod$ go\\s*(\\d\\.\\d+) patterntype:regexp"
            }
          ],
          "dataSeries": [
            {
              "label": "1.14",
              "points": [
                {
                  "value": 2,
                  "dateTime": "2021-04-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2021-06-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2021-08-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2021-10-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2021-12-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2022-02-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2022-04-12T21:44:31Z"
                }
              ]
            },
            {
              "label": "1.16",
              "points": [
                {
                  "value": 6,
                  "dateTime": "2021-04-12T21:44:31Z"
                },
                {
                  "value": 6,
                  "dateTime": "2021-06-12T21:44:31Z"
                },
                {
                  "value": 6,
                  "dateTime": "2021-08-12T21:44:31Z"
                },
                {
                  "value": 5,
                  "dateTime": "2021-10-12T21:44:31Z"
                },
                {
                  "value": 5,
                  "dateTime": "2021-12-12T21:44:31Z"
                },
                {
                  "value": 4,
                  "dateTime": "2022-02-12T21:44:31Z"
                },
                {
                  "value": 4,
                  "dateTime": "2022-04-12T21:44:31Z"
                }
              ]
            },
            {
              "label": "1.17",
              "points": [
                {
                  "value": 0,
                  "dateTime": "2021-04-12T21:44:31Z"
                },
                {
                  "value": 0,
                  "dateTime": "2021-06-12T21:44:31Z"
                },
                {
                  "value": 0,
                  "dateTime": "2021-08-12T21:44:31Z"
                },
                {
                  "value": 2,
                  "dateTime": "2021-10-12T21:44:31Z"
                },
                {
                  "value": 2,
                  "dateTime": "2021-12-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2022-02-12T21:44:31Z"
                },
                {
                  "value": 1,
                  "dateTime": "2022-04-12T21:44:31Z"
                }
              ]
            }
          ]
        }
      ]
    }
  }
}

Merge request reports

Loading