aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api/db
diff options
context:
space:
mode:
Diffstat (limited to 'src/clj/queue_api/db')
-rw-r--r--src/clj/queue_api/db/core.clj15
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