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.clj36
1 files changed, 33 insertions, 3 deletions
diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj
index 40e6188..35a87fd 100644
--- a/src/clj/queue_api/db/core.clj
+++ b/src/clj/queue_api/db/core.clj
@@ -109,10 +109,40 @@
[id]
(let [a (d/entity @conn [:agent/id id])]
(if (not (nil? a))
- (let [p (q-skillset (:primary-skillset a))]
+ (let [p (q-skillset (:agent/primary-skillset a))]
(if (not (nil? p))
p
- (q-skillset (:secondary-skillset a)))))))
+ (q-skillset (:agent/secondary-skillset a)))))))
+
+(defn t-job
+ ([id s]
+ (d/transact! conn [{:job/id id
+ :job/status s}]))
+ ([id s a]
+ (d/transact! conn [{:job/id id
+ :job/status s
+ :job/agent [:agent/id a]}])))
+
+(defn t-agent [id j]
+ (d/transact! conn [{:agent/id id
+ :agent/job [:job/id j]}]))
+(defn end-job [a]
+ (let [jid (-> a :agent/job :job/id)]
+ (if (not (nil? jid))
+ (t-job jid :completed))))
+
+(defn t-agent-job-status
+ [a j]
+ (if (not (nil? j))
+ (do
+ (t-job j :processing a)
+ (t-agent a j)
+ {:job_request {:job_id j :agent_id a}})
+ {:job_request {:job_id nil :agent_id a}}))
(defn dequeue-job [id]
- ) \ No newline at end of file
+ (let [j (request-job id)
+ a (d/entity @conn [:agent/id id])]
+ (if (not (nil? a))
+ (do (end-job a)
+ (t-agent-job-status (-> a :agent/id) (-> j :job/id)))))) \ No newline at end of file