aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-02-17 23:14:17 -0300
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-02-17 23:14:17 -0300
commit65357035e6fee399993da80d6d26aa833979cfcf (patch)
tree86ebc6de8d6c4ff70674403deba887a5983e47e4 /src/clj/queue_api
parent64773838cb5c177994a7d86b557ea464fa06dcd2 (diff)
downloadqueue-api-65357035e6fee399993da80d6d26aa833979cfcf.tar.gz
queue-api-65357035e6fee399993da80d6d26aa833979cfcf.tar.bz2
queue-api-65357035e6fee399993da80d6d26aa833979cfcf.zip
Adds test for db.core
Diffstat (limited to 'src/clj/queue_api')
-rw-r--r--src/clj/queue_api/db/core.clj15
-rw-r--r--src/clj/queue_api/routes/services.clj2
2 files changed, 6 insertions, 11 deletions
diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj
index fa3db41..dc04187 100644
--- a/src/clj/queue_api/db/core.clj
+++ b/src/clj/queue_api/db/core.clj
@@ -1,11 +1,12 @@
(ns queue-api.db.core
(:require [datascript.core :as d]
- [mount.core :as mount]))
+ [mount.core :as mount]
+ [clj-time.core :as time]))
(def schema {:agent/id {:db/unique :db.unique/identity}
:agent/primary-skillset {:db/cardinality :db.cardinality/many}
:agent/secondary-skillset {:db/cardinality :db.cardinality/many}
- :agent/jobs {:db.valueType :db.type/ref}
+ :agent/job {:db.valueType :db.type/ref}
:job/id {:db/unique :db.unique/identity}
:job/agent {:db.valueType :db.type/ref}})
@@ -22,6 +23,7 @@
(d/transact! queue-api.db.core/conn [{:job/id id
:job/type type
:job/urgent urgent
+ :job/date (time/now)
:job/status :unassigned}]))
(defn request-job [id]
@@ -31,13 +33,6 @@
[{:type "Dummy"
:jobs -2}])
-(defn q-agent [id]
- (d/q '[:find ?type :in $ ?id
- :where
- [?e :agent/id ?id]
- [?x :job/type ?type]
- [?x :job/agent ?e]]))
-
(defn q-status [s]
(d/q '[:find ?id :in $ ?status
:where
@@ -45,7 +40,7 @@
[?e :job/id ?id]]
@conn s))
-(defn get-queue []
+(defn sum-queue []
{:completed (map #(first %) (q-status :completed))
:processing (map #(first %) (q-status :processing))
:unassigned (map #(first %) (q-status :unassigned))}) \ No newline at end of file
diff --git a/src/clj/queue_api/routes/services.clj b/src/clj/queue_api/routes/services.clj
index 0e94c18..5d6d6cb 100644
--- a/src/clj/queue_api/routes/services.clj
+++ b/src/clj/queue_api/routes/services.clj
@@ -47,6 +47,6 @@
:processing[String]
:unassigned [String]}
:summary "Get a summary of an agent"
- (ok (db/get-queue)))))
+ (ok (db/sum-queue)))))