Skip to content

insights: Ensure insight ordering on dashboards

Administrator requested to merge insights/api/fix-ordering into main

Created by: CristinaBirkel

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

Description

This does 2 things:

  1. When adding insight views to dashboards, we're now adding them in the order that they were sent in the request. I did this by joining with an in-line table that has them in the right order, and then using that table for ordering.
  2. When fetching a dashboard with insights, a new store method is used, GetAllOnDashboard, which gets the insights on that dashboard in the right order. I also had to reorder the insight views after calling GroupByView, and return the DashboardViewId as the cursor.

Note on pagination: in general this is not supported yet for the insights on dashboards. I think that whenever we decide to finish this, it should work, but I didn't implement it as part of this PR.

Testing Steps

For testing the ordering on the way in:

  1. I re-ran the oob migration locally and verified that the order is preserved in dashboard_insight_view table.
  2. I also tried adding some insights to dashboards via the UI. Before, they would appear in the order that the insights were created, but now they always get added to the bottom.

For testing ordering on the way out:

  1. I used the UI to test this, and just verified that they were appearing on the page in the right order

Merge request reports

Loading