Skip to content

insights: provide default aggregation mode given a query

Warren Gifford requested to merge leo/aggreg-default-mode into main

Created by: leonore

closes #40425 (closed)

follows the logic from the RFC:

Default groupings should be applied in this order (handled by backend):
1. Capture group - if the search query is a regexp and contains a capture group or entire regexp is treated as one group
2. Author - if the search type is commit or diff
3. File - if the search targets a single Repo
4. Repo

Logic for 1. will need to be uncommented with #40714

Test plan

Added unit tests and ran graphql queries for 1, 2, 3, 4 as above + for an invalid query.

query searchQueryAggregate {
  searchQueryAggregate(query: "fix type:file context:global", patternType: literal) {
    aggregations(limit: 10) {
      __typename
      ... on ExhaustiveSearchAggregationResult {
        mode
        groups {
          label
          count
          query
        }
        otherResultCount
        otherGroupCount
      }
      ... on NonExhaustiveSearchAggregationResult {
          mode
          groups {
          label
          count
          query
        }
        otherResultCount
        approximateOtherGroupCount
      }
      ... on SearchAggregationNotAvailable {
        reason
      }
    }
  }
}

Merge request reports

Loading