Add metrics users starred dashboard services
What does this MR do?
It is part part of #214582 (closed) implementation. It adds services that retrieves and adds new entries to metrics_users_starred_dashboard
relation.
Database
All queries where tested on local machine, metrics_users_starred_dashboards
where seeded with 1 010 101 rows.
gitlabhq_development=# select count(1) from metrics_users_starred_dashboards;
count
---------
1010101
(1 row)
Plan for query used by scope for_project
gitlabhq_development=# EXPLAIN (ANALYZE) SELECT * FROM metrics_users_starred_dashboards WHERE project_id = 2;
QUERY PLAN
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using index_metrics_users_starred_dashboards_on_project_id on metrics_users_starred_dashboards (cost=0.42..12618.34 rows=57273 width=57) (actual time=0.065..69.980 rows=56476 loops=1)
Index Cond: (project_id = 2)
Planning time: 0.993 ms
Execution time: 73.642 ms
(4 rows)
Plan for query used by scope for_project_dashboard
gitlabhq_development=# EXPLAIN (ANALYZE) SELECT * FROM metrics_users_starred_dashboards WHERE project_id = 1 AND dashboard_path = 'dashboard_1_1';
QUERY PLAN
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using index_metrics_users_starred_dashboards_on_project_id on metrics_users_starred_dashboards (cost=0.42..12755.80 rows=1 width=57) (actual time=602.615..602.615 rows=0 loops=1)
Index Cond: (project_id = 1)
Filter: (dashboard_path = 'dashboard_1_1'::text)
Rows Removed by Filter: 56580
Planning time: 3.639 ms
Execution time: 602.676 ms
(6 rows)
Plan for query executed from starred_dashboards.for_project(project)
gitlabhq_development=# EXPLAIN (ANALYZE) SELECT * FROM metrics_users_starred_dashboards WHERE user_id = 2 AND project_id = 1;
QUERY PLAN
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Index Scan using idx_metrics_users_starred_dashboard_on_user_project_dashboard on metrics_users_starred_dashboards (cost=0.42..1262.67 rows=1289 width=57) (actual time=0.043..1.064 rows=1242 loops=1)
Index Cond: ((user_id = 2) AND (project_id = 1))
Planning time: 0.094 ms
Execution time: 1.189 ms
(4 rows)
Plan for query executed from starred_dashboards.for_project_dashboard(project, params[:dashboard_path])
gitlabhq_development=# EXPLAIN (ANALYZE) SELECT * FROM metrics_users_starred_dashboards WHERE user_id = 2 AND project_id = 1 AND dashboard_path = 'dashboard_1_1';
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.031..0.032 rows=0 loops=1)
Index Cond: ((user_id = 2) AND (project_id = 1) AND (dashboard_path = 'dashboard_1_1'::text))
Planning time: 0.096 ms
Execution time: 0.049 ms
(4 rows)
Entry creation estimation for starred_dashboard.save
gitlabhq_development=# EXPLAIN (ANALYZE) INSERT INTO metrics_users_starred_dashboards (user_id, project_id, dashboard_path, created_at, updated_at) VALUES (2, 1, 'test_path', NOW(), NOW());
QUERY PLAN
-------------------------------------------------------------------------------------------------------------------------
Insert on metrics_users_starred_dashboards (cost=0.00..0.02 rows=1 width=72) (actual time=0.203..0.203 rows=0 loops=1)
-> Result (cost=0.00..0.02 rows=1 width=72) (actual time=0.005..0.006 rows=1 loops=1)
Planning time: 0.023 ms
Trigger for constraint fk_bd6ae32fac: time=11.737 calls=1
Trigger for constraint fk_d76a2b9a8c: time=7.633 calls=1
Execution time: 19.594 ms
(6 rows)
Screenshots
Does this MR meet the acceptance criteria?
Conformity
-
[ ] Changelog entry//no user facing changes, nor new migration added in the scope of this MR -
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