 (ns metabase.pulse
   (:require [hiccup.core :refer [html]]
+            [clj-time.core :as t]
+            [clj-time.coerce :as c]
+            [clj-time.format :as f]
             [clojure.tools.logging :as log]
             [clojure.pprint :refer [cl-format]]
             [clojure.string :refer [upper-case]]

          ymax (apply max ys)
          yrange (- ymax ymin)
          ys' (map #(/ (- % ymin) yrange) ys)]
      [:img {:src (generate-data-uri (render-sparkline-to-png xs' ys' 300 200) "image/png")}]))

(defn render-pulse-card
  [card data include-title]

(def ^:private bar-th-style  (str font-style "font-size: 10px; font-weight: 400; color: rgb(57,67,64); border-bottom: 4px solid rgb(248, 248, 248); padding-top: 0px; padding-bottom: 10px;"))
(def ^:private bar-td-style  (str font-style "font-size: 16px; font-weight: 400; text-align: left; padding-right: 1em; padding-top: 8px;"))

(defn- format-number
  [n]
  (if (integer? n) (cl-format nil "~:d" n) (cl-format nil "~,2f" n)))

(defn- format-number-short
  [n]
  (cond
    (>= n 1000000000) (str (cl-format nil "~,1f" (/ n 1000000000.0)) "B")
    (>= n 1000000) (str (cl-format nil "~,1f" (/ n 1000000.0)) "M")
    (>= n 1000) (str (cl-format nil "~,1f" (/ n 1000.0)) "K")
    :else (str (cl-format nil "~,1f" n))))

(defn- format-timestamp
  [timestamp]
  (let [date (c/from-long timestamp)
        today (t/today-at 0 00)]
    (cond
      (t/within? (t/interval today (t/plus today (t/days 1))) date) "Today"
      (t/within? (t/interval (t/minus today (t/days 1)) today) date) "Yesterday"
      :else (f/unparse (f/formatter "MMM d, YYYY") date))))

(defn render-bar-chart-row
  [index row max-value]
