diff options
Diffstat (limited to 'src/clj/queue_api/db')
-rw-r--r-- | src/clj/queue_api/db/core.clj | 26 |
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)) |