aboutsummaryrefslogtreecommitdiff
path: root/src/clj/queue_api
diff options
context:
space:
mode:
authorGabriel A. Giovanini <mail@gabrielgio.me>2018-02-20 13:22:08 -0300
committerGabriel A. Giovanini <mail@gabrielgio.me>2018-02-20 13:22:08 -0300
commit1467bfae9c7971ba04429a1741d6d8549f5acbe2 (patch)
treedb795303d1ad2a394c015aadd3d79d0e8d6ed26b /src/clj/queue_api
parentc3fadc2baa620fb949944c1876a65c72e17fcb09 (diff)
downloadqueue-api-1467bfae9c7971ba04429a1741d6d8549f5acbe2.tar.gz
queue-api-1467bfae9c7971ba04429a1741d6d8549f5acbe2.tar.bz2
queue-api-1467bfae9c7971ba04429a1741d6d8549f5acbe2.zip
Adds more test and doc
Diffstat (limited to 'src/clj/queue_api')
-rw-r--r--src/clj/queue_api/db/core.clj26
1 files changed, 13 insertions, 13 deletions
diff --git a/src/clj/queue_api/db/core.clj b/src/clj/queue_api/db/core.clj
index 0381e1e..3210a6c 100644
--- a/src/clj/queue_api/db/core.clj
+++ b/src/clj/queue_api/db/core.clj
@@ -36,18 +36,18 @@
(defn agent-jobs
"Get a job that has a agent bounded with given `id` and a status of `s`"
[id s]
- (let [q (d/q '[:find ?jid
- :in $ ?id ?s
- :where
- [?e :agent/id ?id]
- [?x :job/id ?jid]
- [?x :job/status ?s]
- [?x :job/agent ?e]]
- @conn id s)]
- (map #(d/entity @conn [:job/id (first %)]) q)))
+ (->> (d/q '[:find ?jid
+ :in $ ?id ?s
+ :where
+ [?e :agent/id ?id]
+ [?x :job/id ?jid]
+ [?x :job/status ?s]
+ [?x :job/agent ?e]]
+ @conn id s)
+ (map #(d/entity @conn [:job/id (first %)]))))
(defn q-job
- "Fetch job and sort by date
+ "Query jobs and sort them by date
`u`: urgent flag
`s`: status of the job
`ts`: types of the job"
@@ -66,7 +66,7 @@
(map #(d/entity @conn [:job/id (last %)]))))
(defn q-status
- "Query job filtering only by `s`"
+ "Query job by status `s`"
[s]
(d/q '[:find ?id :in $ ?status
:where
@@ -75,7 +75,7 @@
@conn s))
(defn sum-agent
- "Get how many jobs a agent (`id`) has performed aggregated by type"
+ "Get how many jobs a agent `id` has performed aggregated by type"
[id]
(let [jobs (agent-jobs id :completed)]
(reduce (fn [l r]
@@ -85,7 +85,7 @@
(conj l {t (inc (get l t))})))) {} jobs)))
(defn sum-queue
- "Count all job aggregated by type"
+ "Count all jobs aggregated by type"
[]
{:completed (map first (q-status :completed))
:processing (map first (q-status :processing))