Metabase is lacking in some of the management information I’d like to see. Hopefully the queries below will help a few others build up a management dashboard too.
In summary:
- List of Dashboards
- List of Questions
- List of Questions in each Dashboard
- List of Questions not in any Dashboard
- List of Users
- LIst of Users who have never logged in
- List of Dashboards viewed by each user and count of views
- Pretty much anything else you can dream up
/* All dashboards */
SELECT rd.id, rd.name, rd.description, rd.archived FROM report_dashboard rd;
/* All questions */
select q.id, q.name, q.description, q.archived, q.display, q.query_type
from report_card q;
/* Current dashboards and their questions */
SELECT rd.id, rd.name as DashboardName, rd.description as DashboardQuestion, q.name as QuestionName, q.description as QuestionDescription, q.display as QuestionDisplay
FROM report_dashboard rd
INNER JOIN report_dashboardcard rdc on rd.id = rdc.dashboard_id
INNER JOIN report_card q on q.id = rdc.card_id
where rd.archived = 0 and q.archived = 0;
/* Questions without a dashboard */
select q.id, q.name, q.description, q.display, q.query_type
from report_card q
LEFT OUTER JOIN report_dashboardcard rdc on rdc.card_id = q.id
where q.archived = 0 and rdc.card_id is null;
/* users who have never logged in */
select id, email, first_name, last_name
from core_user
where last_login is null;
/* which dashboards has a user viewed */
select count(cu.id) as viewCount, cu.email, cu.first_name, cu.last_name, rd.name as DashboardName, rd.description as DashboardDescription
from core_user cu
INNER JOIN view_log vl on vl.user_id = cu.id
INNER JOIN report_dashboard rd on rd.id = vl.model_id
where vl.model='dashboard'
GROUP BY cu.email, cu.first_name, cu.last_name, rd.name, rd.description