Skip to content

insights: Remove close points before returning dataSeries

Administrator requested to merge insights/close-points into main

Created by: CristinaBirkel

Closes https://github.com/sourcegraph/sourcegraph/issues/30642

Description

The issue is that the background process that takes snapshots is imperfect, and we sometimes end up with points that are not exactly duplicates, but too close together to make sense of in the UI. This PR removes points that are "too close together," meaning:

  • Any points that are closer than 20% of the time interval are removed. (The second of the two close points is removed.)
  • The exception is the very last point which is the most recent daily snapshot.

What do you think? I'm not quite sure it's the cleanest solution, but it seems like it will solve the problem.

Test plan

I tested this out by adding some very close snapshot points to the database and seeing that they get removed. Also added this as a standalone function so it could be easily unit tested.

Merge request reports

Loading