Create starred metrics dashboards relation
Problem
Let's introduce a way to access the most accessed/requested dashboards in the dashboard dropdown menu by allowing users to "star" their most used dashboards and showing them first in the dashboard dropdown. the dashboard list changes depending on the user
From &3079
What does this MR do?
Adds database relation to persist starred dashboards information from #214582 (closed)
Database
The intended use cases are: fetching all dashboards "starred" by user for given project (that leads to query SELECT * FROM metrics_users_starred_dashboards WHERE user_id = 23 AND project_id = 21
) or to check if given dashboard is "starred" (SELECT * FROM metrics_users_starred_dashboards WHERE user_id = 23 AND project_id = 21 AND dashboard_path = 'dashboard_100_9868';
) because of that index on user_id, project_id and dashboard_path
was added, from the very begging.
Query plan of intended query tested on local instance seeded with 1 010 101 rows
gitlabhq_development=# EXPLAIN (ANALYZE, BUFFERS) SELECT * FROM metrics_users_starred_dashboards WHERE user_id = 23 AND project_id = 21 AND dashboard_path = 'dashboard_100_9868';
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using idx_metrics_users_starred_dashboard_on_user_project_dashboard on metrics_users_starred_dashboards (cost=0.42..2.45 rows=1 width=57) (actual time=0.083..0.084 rows=1 loops=1)
Index Cond: ((user_id = 23) AND (project_id = 21) AND ((dashboard_path)::text = 'dashboard_100_9868'::text))
Buffers: shared hit=7
Planning time: 0.759 ms
Execution time: 0.138 ms
(5 rows)
gitlabhq_development=# SELECT count(1) FROM metrics_users_starred_dashboards;
count
---------
1010101
(1 row)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
Changelog entry - [-] Documentation (if required)
-
Code review guidelines -
Merge request performance guidelines -
Style guides -
Database guides - [-] Separation of EE specific content
Availability and Testing
-
Review and add/update tests for this feature/bug. Consider all test levels. See the Test Planning Process. - [-] Tested in all supported browsers
- [-] Informed Infrastructure department of a default or new setting change, if applicable per definition of done
Security
If this MR contains changes to processing or storing of credentials or tokens, authorization and authentication methods and other items described in the security review guidelines:
- [-] Label as security and @ mention
@gitlab-com/gl-security/appsec
- [-] The MR includes necessary changes to maintain consistency between UI, API, email, or other methods
- [-] Security reports checked/validated by a reviewer from the AppSec team