From fc432d64c167dc2e6a17ae650e5fa8e772c4fbe8 Mon Sep 17 00:00:00 2001 From: "Gabriel A. Giovanini" Date: Tue, 20 Feb 2018 22:29:01 -0300 Subject: README --- README.md | 19 ++++++++++++++++++- src/clj/queue_api/routes/services.clj | 4 +--- test/clj/queue_api/test/handler.clj | 2 +- 3 files changed, 20 insertions(+), 5 deletions(-) diff --git a/README.md b/README.md index f171e30..1686dd4 100644 --- a/README.md +++ b/README.md @@ -37,7 +37,7 @@ Additionally it had an okay [non-documentation](https://github.com/tonsky/datasc ### Data structure -Project has two model: +Project has two models: * Agent * `:agent/id` unique identification of an agent @@ -65,6 +65,23 @@ Those models wrap up in schema: :job/agent {:db.valueType :db.type/ref}} ``` +### services.clj + +After all luminus file there is actually two files that have the core logic of the app `services.clj` and `db/core.cljs`. +For `services.clj` it holds all code for endpoint definition and model validation and considering the exercise requirements we gonna need 5 endpoints: + +* Endpoint to add agent is a`:put` at `/agent` +* Endpoint to get how many jobs of each type this agent has performed is a `:post` at `/agent`. Note: usually since it is a method that doesn't modify anything I would have used `:get` and pass the agent id via path (`/agent/:id`) but one of the requirement is "*All endpoints should accept and return JSON content type payloads*" I worked with POST PUT. +* Endpoint to add a job is `:put` at `/job` +* Endpoint to request a job is `:post` at `/job` +* Endpoint to get current queue state is `:get` at `/job` + +For model detail access swagger-ui. + +### db/core.clj + +To be continued... + diff --git a/src/clj/queue_api/routes/services.clj b/src/clj/queue_api/routes/services.clj index dee949a..0b26281 100644 --- a/src/clj/queue_api/routes/services.clj +++ b/src/clj/queue_api/routes/services.clj @@ -47,10 +47,8 @@ (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}}))))) + (ok {:job_request {:job_id j :agent_id agent_id}})))) - (context "/queue" [] - :tags ["queue"] (GET "/" [] :return {:completed [String] :processing [String] diff --git a/test/clj/queue_api/test/handler.clj b/test/clj/queue_api/test/handler.clj index 3473ce8..04e9912 100644 --- a/test/clj/queue_api/test/handler.clj +++ b/test/clj/queue_api/test/handler.clj @@ -42,7 +42,7 @@ (deftest queue-test (testing "Queue route" - (let [response (app (request :get "/queue"))] + (let [response (app (request :get "/job"))] (is (= 200 (:status response)))))) (deftest invalid-test -- cgit v1.2.3