insights: Ensure insight ordering on dashboards
Created by: CristinaBirkel
Closes: https://github.com/sourcegraph/sourcegraph/issues/28700
Description
This does 2 things:
- 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.
- 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 callingGroupByView
, and return theDashboardViewId
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:
- I re-ran the oob migration locally and verified that the order is preserved in
dashboard_insight_view
table. - 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:
- I used the UI to test this, and just verified that they were appearing on the page in the right order