Running a code insight over a timeframe when the repo didn't yet exist in Sourcegraph breaks the entire insight, but it should just not display data for that date(s)
Created by: Joelkw
- Sourcegraph version: 3.27 and earlier
Steps to reproduce:
- Go to any code insight in dotcom settings
- Change the step to be something large, like
"years": 2or similar (so shows 14 years on the chart) - View the insight and you'll see:
The cause of this bug is that bulkSearchCommits doesn't find a commit, and then it breaks the insight when it runs the query over the commits returned from bulkSearchCommits (because there's no commit that existed).
Expected behavior:
We should modify so that instead of breaking the insight, the graph should just show no points if we don't find a commit. This means it may only show 3-4 points; that's fine. We should keep the timeframe x-axis the same length to illustrate this. (Strong hypothesis: most folks, if they see a graph that starts midway along the x-axis, will understand it's due to lack of data before that).
Additional functionality if time or for later iterations: for the earliest-in-time commit that we do have, we should include that to demonstrate that's the starting point of the graph.
For example, let's say I have a repo that only has commits synced to Sourcegraph dating back to August 2017, and I want a code insight that runs over the last 7 years starting now (May). I would see a datapoint for May '21, May '20, May '19, May '18, Aug '17, and then nothing else.
Caveat to the above: If there are multiple repos for the data series, we should simply count "pre-repo-existed" datapoints as 0. If the time-axis pre-dates all repos in the insight, then we should do the "first datapoint" on the graph for the earliest time at least 1 repo existed, and otherwise continue to sum the results count from the other repos as 0 until data exists.
This means in the earlier example if 1 repo dates back to August 2017 and another dates back to November 2017 – and my graph marks points 1 per year in May (now) – then I'll see an august '17 data point from repo 1 (and no Nov 2017 datapoint), and then the May 2018 datapoint will include total result count from both repos.
Stretch goal (later iteration): we should non-blocking warn you on insight creation if your timeframe extends past the date of your insight, just so you are aware, and suggest the earliest available timeframe that has data.
Actual behavior:
It breaks the insight and shows nothing at all but the error message.
