insights: determine if query targets a single repo#39382
Conversation
|
Codenotify: Notifying subscribers in CODENOTIFY files for diff 98c48b2...88b0a57.
|
| var QueryNotSupported = errors.New("query not supported") | ||
|
|
||
| // IsSingleRepoQuery - Returns a boolean indicating if the query provided targets only a single repo. | ||
| // At this time only queries with a single query plan step are supported. Queries with multiple plan steps |
There was a problem hiding this comment.
Does this mean something like repo:A thing OR repo:B thing won't work?
There was a problem hiding this comment.
@coury-clark at this point that query would kick back the QueryNotSupported error (probably a better name available for that). The issue with repo:A thing OR repo:B thing is that parsing it returns back a 2 step query plan where each step targets a single repo:
- repo:a thing
- repo:b thing
For simplicity in this first version I made the decision to halt processing on any multi step query plans as unsupported. We could introduce additional logic to check that each step is single repo AND that it is the same repo, I believe that would be simple but I didn't want to get too deep into possibilities of what could occur in more complex query plans.
The following query repo:a thing OR thing2 returns back a single step so something similar to that would not have the same issue.
Adds a new function to the insights query builder package that can determine if a query is targeting a single repo. This will initially be used as one piece of criteria to determine if a search query is eligible to run additional queries to provide additional insights such as % change over time or a small preview of an insight.
Currently only supports queries with a 1 step query plan.
resolves #39241
Test plan
added unit tests pass