diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2018-02-18 21:00:55 -0300 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2018-02-18 21:00:55 -0300 |
commit | 9dd6aeb32d21ed8673bdd490341302fd7f37d2fc (patch) | |
tree | 8362688060eaea737f40ddf514648a22f8c2d4fe /src/clj/queue_api/db/core.clj | |
parent | 48bd546122842012a65572fa436fe58cfd965ca7 (diff) | |
download | queue-api-9dd6aeb32d21ed8673bdd490341302fd7f37d2fc.tar.gz queue-api-9dd6aeb32d21ed8673bdd490341302fd7f37d2fc.tar.bz2 queue-api-9dd6aeb32d21ed8673bdd490341302fd7f37d2fc.zip |
Adds functions that were missing
Diffstat (limited to 'src/clj/queue_api/db/core.clj')
-rw-r--r-- | src/clj/queue_api/db/core.clj | 36 |
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 |