   (post-resource (:device-1 urls) "application/json" (:device-1 resources))
 
   (db/with-session [session (:hecuba-session store)]
-    (db/execute session 
+    (db/execute session
                 (hayt/insert :entities (hayt/values {:id "14366c761c74592b9926e851bae8a64ece7239ff"
                                                      :project_id "ba776928f94b3aaa1e444569276ee5b66d6b21f7"})))
-    (db/execute session 
+    (db/execute session
                 (hayt/insert :entities (hayt/values {:id "9ac7f5635832d843dda594f58525239263ffdd37"
                                                      :project_id "ba776928f94b3aaa1e444569276ee5b66d6b21f7"}))))
-  
+  ;; cos we're bypassing the api above need to refresh ES.
+  (kixi.hecuba.data.entities.search/refresh-search
+   (:hecuba-session store) (:search-session store))
+
   (post-resource (:device-2 urls) "application/json" (:device-2 resources))
   (post-resource (:device-3 urls) "application/json" (:device-3 resources))
   (post-resource (:device-3 urls) "application/json" (:device-4 resources))

    (let [measurements4 (map #(zipmap [:device_id :type :month :timestamp :error :reading_metadata :metadata :value] %)
                             (rest (csv/read-csv in-file3)))
           m4 (map #(update-in % [:timestamp] (fn [t] (let [d (tf/parse (tf/formatter  "yyyy-MM-dd HH:mm:ssZ") t)]
                                                      (tf/unparse 
                                                       (tf/formatter "yyyy-MM-dd HH:mm:ssZ")
                                                       (t/minus (t/plus d (t/years 2)) (t/days 9))))))
                   measurements4)]


(defn load-test-data [system]
  (let [store (:store system)]

    (post-contextual-data store)
    (post-readings)
    (post-generated-measurements)))

;; To load data (load-test-data system)
