   (let [service-mode (str/lower-case (name (first (keys (get-in service [:Spec :Mode])))))
         service-name (get-in service [:Spec :Name])
         service-id (get service :ID)
-        service-tasks (-> (filter #(= (:ServiceID %) service-id) tasks)
-                          (->tasks nodes service-name service-mode))
+        service-tasks (filter #(= (:ServiceID %) service-id) tasks)
         replicas (get-in service [:Spec :Mode :Replicated :Replicas])
-        replicas-running (-> (filter #(= (:state %) "running") service-tasks)
-                             (count))
+        replicas-running (->service-replicas-running service-tasks)
         image (get-in service [:Spec :TaskTemplate :ContainerSpec :Image])
         image-info (str/split image #"@")
         image-name (first image-info)

      :id id
      :taskName task-name
      :version (get-in task [:Version :Index])
      :createdAt (get task :CreatedAt)
      :updatedAt (get task :UpdatedAt)
      :image image-name
      :imageDigest image-digest
      :state (get-in task [:Status :State])

(ns swarmpit.docker.mapper.inbound
  "Map docker domain to swarmpit domain"
  (:import (java.text SimpleDateFormat))
  (:require [clojure.string :as str]))

(def date-format (SimpleDateFormat. "yyyy-MM-dd'T'HH:mm:ss"))

(defn date
  [date]
  (str (.parse date-format date)))

(defn ->node
  [node]
