                                          payload)))]
     (-> command
         (assoc :payload validated-payload)
-        (store-report* db))))
+        (store-report* start-time db))))
 
 ;; ## Command processors
 

;; Catalog replacement

(defn replace-catalog*
  [{:keys [certname version id received payload]} db]
  (let [{producer-timestamp :producer_timestamp :as catalog} payload]
    (jdbc/with-transacted-connection' db :repeatable-read
      (scf-storage/maybe-activate-node! certname producer-timestamp)
      (scf-storage/replace-catalog! catalog received))
    (log/info (trs "[{0}-{1}] ''{2}'' command processed for {3}"
                   (str id)
                   (str (tcoerce/to-long received))
                   (command-names :replace-catalog)
                   certname))))

(defn replace-catalog [{:keys [payload received version] :as command} db]
  (let [validated-payload (upon-error-throw-fatality
                           (cat/parse-catalog payload version received))]
    (-> command
        (assoc :payload validated-payload)
        (replace-catalog* db))))

;; Fact replacement

(defn replace-facts*
  [{:keys [payload id received] :as command} db]
  (let [{:keys [certname values] :as fact-data} payload
        producer-timestamp (:producer_timestamp fact-data)]
    (jdbc/with-transacted-connection' db :repeatable-read
      (scf-storage/maybe-activate-node! certname producer-timestamp)
      (scf-storage/replace-facts! fact-data))
    (log/info (trs "[{0}-{1}] ''{2}'' command processed for {3}"
                   (str id)
                   (str (tcoerce/to-long received))
                   (command-names :replace-facts)
                   certname))))

(defn replace-facts [{:keys [payload version received] :as command} db]
  (replace-facts* (upon-error-throw-fatality
                   (assoc command :payload (fact/normalize-facts version received payload)))
                  db))

;; Node deactivation

            [schema.core :as s]
            [puppetlabs.puppetdb.config :as conf]
            [puppetlabs.puppetdb.time :refer [to-timestamp]]
            [clj-time.core :as time :refer [now interval in-millis]]
            [clj-time.format :as fmt-time]
            [clojure.set :as set]
            [clojure.core.async :as async]
