 (defn- label-metrics
   "Get metrics based on labels"
   []
-  (let [labels (db/select 'CardLabel)]
+  (let [labels (db/select ['CardLabel :card_id :label_id])]
     {:labels (count labels)
      :num_labels_per_card (micro-histogram labels :card_id)
      :num_cards_per_label (medium-histogram labels :label_id)}))

(defn- field-metrics
  "Get metrics based on fields"
  []
  (let [fields (db/select 'Field)]
    {:fields (count fields)
     :num_per_table (medium-histogram fields :table_id)}))

(defn- segment-metrics
  "Get metrics based on segments"
  []
  (let [segments (db/select 'Segment)]
    {:segments (count segments)}))


(defn- metric-metrics
  "Get metrics based on metrics"
  []
  (let [metrics (db/select 'Metric)]
    {:metrics (count metrics)}))



  "Get metrics based on questions
  TODO characterize by # executions and avg latency"
  []
  (let [questions (db/select ['Card :id :query_type])]
    {:questions (apply add-summaries (map question-dims questions))}))

(defn- dashboard-metrics
  "Get metrics based on dashboards
  TODO characterize by # of revisions, and created by an admin"
  []
  (let [dashboards (db/select ['Dashboard :id :creator_id])
        dashcards (db/select ['DashboardCard :id :card_id :dashboard_id])]
    {:dashboards (count dashboards)
     :num_dashs_per_user (medium-histogram dashboards :creator_id)
     :num_cards_per_dash (medium-histogram dashcards :dashboard_id)
