From 65357035e6fee399993da80d6d26aa833979cfcf Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Sat, 17 Feb 2018 23:14:17 -0300 Subject: Adds test for db.core --- src/clj/queue_api/db/core.clj | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) (limited to 'src/clj/queue_api/db/core.clj') 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 -- cgit v1.2.3