Skip to content

insights: Backend work to sort series

Created by: CristinaBirkel

Continuing off of spike ticket: https://github.com/sourcegraph/sourcegraph/issues/33930

API changes:

  1. createLineChartSearchInsight: anything needed here? Do we want users be able to set this at creation time?
  2. updateLineChartSearchInsight: I believe changes here will be needed in order to persist the sort order and display count. Which I think we want to be able to do? That's what I did in this draft PR. Any thoughts here about the structure?
  3. insightViews: I assume we'll need to add an additional argument to take the sort filters. I didn't consider this use case at first and will need to add it into the PR. I wonder in general if this belongs with the filters argument, or is a separate thing? It's not really a filter.
  4. Any other API changes needed?

As far as sorting options, I've added these:

enum SeriesSortOrder {
    HIGHEST_RESULT_COUNT
    LOWEST_RESULT_COUNT
    ASC_LEXICOGRAPHICAL
    DESC_LEXICOGRAPHICAL
}

I may need to add OLDEST and LATEST as well, given the designs.

I think one open question is whether this applies only to capture group insights. There may be conflicting thoughts there. Right now I'm storing this metadata at the insight_view level, but if it's only for capture group series I wonder if it belongs on the capture group series itself.