Skip to content

insights: default to fork:no archived:no for code insights queries

Administrator requested to merge insights/fork-archive into main

Created by: coury-clark

Default code insights queries to using fork:no archive:no. This doesn't propagate to insights calculated on the frontend. This will preserve user inputted values if provided.

Test plan

Example tests on the live preview resolver against a fork repo.

{
  "input": {
    "series": [
      {
        "generatedFromCaptureGroups": false,
        "query": "Messages file:^protocol\\.md",
        "label": "abc"
      }
    ],
    "repositoryScope": {
      "repositories": [
        "github.com/sourcegraph/language-server-protocol"
      ]
    },
    "timeScope": {
      "stepInterval": {
        "unit": "MONTH",
        "value": 1
      }
    }
  }
}
{
  "data": {
    "searchInsightPreview": [
      {
        "points": [
          {
            "dateTime": "2021-11-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2021-12-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2022-01-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2022-02-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2022-03-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2022-04-11T00:00:00Z",
            "value": 0
          },
          {
            "dateTime": "2022-05-11T00:00:00Z",
            "value": 0
          }
        ]
      }
    ]
  }
}

Example of one of the generated queries: archived:no fork:only file:^protocol\.md count:99999999 Messages repo:^github\.com/sourcegraph/language-server-protocol$@6f083d7cf03fb2a282b1f940d31c15b400ae7df6

Changing the query to Messages fork:yes file:^protocol\\.md

{
  "data": {
    "searchInsightPreview": [
      {
        "points": [
          {
            "dateTime": "2021-11-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2021-12-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2022-01-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2022-02-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2022-03-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2022-04-11T00:00:00Z",
            "value": 5
          },
          {
            "dateTime": "2022-05-11T00:00:00Z",
            "value": 5
          }
        ]
      }
    ]
  }
}

Merge request reports

Loading