diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2018-02-17 23:14:17 -0300 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2018-02-17 23:14:17 -0300 |
commit | 65357035e6fee399993da80d6d26aa833979cfcf (patch) | |
tree | 86ebc6de8d6c4ff70674403deba887a5983e47e4 /src/clj/queue_api/db | |
parent | 64773838cb5c177994a7d86b557ea464fa06dcd2 (diff) | |
download | queue-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/db')
-rw-r--r-- | src/clj/queue_api/db/core.clj | 15 |
1 files changed, 5 insertions, 10 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 |