aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-02-20 00:04:08 -0300
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-02-20 00:04:08 -0300
commitd1c15fe5fa8d5aac6a7ca056e79ca8872971a9d9 (patch)
tree86f0b7c3d3efe68c6ec2dde770487d3fe2fe18ef /src
parent8e06fdb6f18e8cc63a5d501e68a175685fb808b5 (diff)
downloadqueue-api-d1c15fe5fa8d5aac6a7ca056e79ca8872971a9d9.tar.gz
queue-api-d1c15fe5fa8d5aac6a7ca056e79ca8872971a9d9.tar.bz2
queue-api-d1c15fe5fa8d5aac6a7ca056e79ca8872971a9d9.zip
Even more test
Diffstat (limited to 'src')
-rw-r--r--src/clj/queue_api/db/core.clj15
-rw-r--r--src/clj/queue_api/routes/services.clj7
2 files changed, 11 insertions, 11 deletions
diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj
index f40548c..faa4d65 100644
--- a/src/clj/queue_api/db/core.clj
+++ b/src/clj/queue_api/db/core.clj
@@ -78,14 +78,11 @@
"Get how many jobs a agent (`id`) has performed aggregated by type"
[id]
(let [jobs (agent-jobs id :completed)]
- (->> (reduce (fn [l r]
- (let [t (:job/type r)]
- (if (nil? (get l t))
- (conj l {t 1})
- (conj l {t (inc (get l t))})))) {} jobs)
- (map (fn [x]
- {:type (first x)
- :jobs (last x)})))))
+ (reduce (fn [l r]
+ (let [t (:job/type r)]
+ (if (nil? (get l t))
+ (conj l {t 1})
+ (conj l {t (inc (get l t))})))) {} jobs)))
(defn sum-queue
"Count all job aggregated by type"
@@ -154,4 +151,4 @@
(let [jid (-> (request-job id) :job/id)]
(end-job a)
(start-job id jid)
- {:job_id jid :agent_id id})))) \ No newline at end of file
+ jid)))) \ 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 694f0d8..dee949a 100644
--- a/src/clj/queue_api/routes/services.clj
+++ b/src/clj/queue_api/routes/services.clj
@@ -26,7 +26,10 @@
:return [{:type String :jobs s/Int}]
:body-params [agent_id :- String]
:summary "Get summary of an agent"
- (ok (db/sum-agent agent_id))))
+ (let [jobs (db/sum-agent agent_id)]
+ (map (fn [x]
+ {:type (first x)
+ :jobs (last x)}) jobs))))
(context "/job" []
:tags ["job"]
@@ -44,7 +47,7 @@
(let [j (db/dequeue-job agent_id)]
(if (nil? j)
(bad-request {:message "Agent does not exist"})
- (ok {:job_request j})))))
+ (ok {:job_request {:job_id j :agent_id agent_id}})))))
(context "/queue" []
:tags ["queue"]