           group (when group-uuid
                   [{:db/id (d/tempid :db.part/user)
                     :group/uuid (java.util.UUID/fromString group-uuid)
-                    :group/job job-id }])
+                    :group/job job-id}])
           txn [runtime-env
                status-env
                commit-latch

                                              :complete-trigger-chan complete-trigger-chan
                                              :state-atom state-atom))
        config (merge {:shares [{:user "default" :mem 4000.0 :cpus 4.0 :gpus 1.0}]
                       :time-ms-between-rebalancing (-> 30 t/minutes t/in-millis)}
                      config)
        opt-config {:host-feed {:create-fn 'cook.mesos.optimizer/create-dummy-host-feed

  (let [job (:job/_instance task)
        resources (util/job-ent->resources job)
        group (first (:group/_job job))]
    {:job_id (str (:job/uuid job))
     :instance_id (:instance/task-id task)
     :submit_time_ms (.getTime (:job/submit-time job))
     :mesos_start_time_ms (if (:instance/mesos-start-time task)
                            (.getTime (:instance/mesos-start-time task))
                            -1)
     :group_id (:group/uuid group)
     :start_time_ms (.getTime (:instance/start-time task))
     :end_time_ms (.getTime (or (:instance/end-time task) (tc/to-date (t/now))))
     :expected_run_time (:job/expected-runtime job)
     :status (:instance/status task)
     :hostname (:instance/hostname task)
     :slave_id (:instance/slave-id task)
     :reason (or (when (= (:instance/status task) :instance.status/failed)
                   (:reason/string (:instance/reason task)))
                 "")
     :user (:job/user job)
     :mem (or (:mem resources) -1)
     :cpus (or (:cpus resources) -1)
     :job_name (or (:job/name job) "")
     :requested_run_time (->> (:job/label job)
                              (filter #(= (:label/key %) "JOB-RUNTIME"))
                              first
                              :label/value)
     :requested_status (->> (:job/label job)
                            (filter #(= (:label/key %) "JOB-STATUS"))
                            first
                            :label/value)}))

(defn dump-jobs-to-csv
  "Given a mesos db, dump a csv with a row per task"
