diff options
Diffstat (limited to 'src/clj')
-rw-r--r-- | src/clj/queue_api/db/core.clj | 15 | ||||
-rw-r--r-- | src/clj/queue_api/routes/services.clj | 2 |
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))))) |