From 0b8277f72cdc2ed2abeb566f30958bd8e0dc5167 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Wed, 21 Feb 2018 22:41:20 -0300 Subject: Readme and validation --- src/clj/queue_api/routes/services.clj | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'src/clj/queue_api/routes') diff --git a/src/clj/queue_api/routes/services.clj b/src/clj/queue_api/routes/services.clj index 0b26281..766f831 100644 --- a/src/clj/queue_api/routes/services.clj +++ b/src/clj/queue_api/routes/services.clj @@ -44,10 +44,14 @@ :return {:job_request {:job_id s/Any :agent_id String}} :body-params [agent_id :- String] :summary "Request a job to a given agent" - (let [j (db/dequeue-job agent_id)] - (if (nil? j) - (bad-request {:message "Agent does not exist"}) - (ok {:job_request {:job_id j :agent_id agent_id}})))) + + (let [a (agent agent_id)] + (if (nil? a) + (not-found {:message "Agent does not exist"})) + (let [j (db/dequeue-job agent_id)] + (if (nil? j) + (not-found {:message "There is no job available for given agent"}) + (ok {:job_request {:job_id j :agent_id agent_id}}))))) (GET "/" [] :return {:completed [String] -- cgit v1.2.3