From 75760dd30d5ea91e5658c48f2de8766fc69fa00c Mon Sep 17 00:00:00 2001 From: Jake Mensch Date: Fri, 31 Jul 2020 05:30:35 -0700 Subject: [PATCH 1/3] /map/pins endpoint --- .gitignore | 1 + server/api/src/app.py | 3 ++ server/api/src/control/route_handlers.py | 9 ++++ server/api/src/services/map.py | 15 ++++++ .../311-CI.postman_collection.json | 48 ++++++++++++++++++ .../311-all.postman_collection.json | 50 ++++++++++++++++++- 6 files changed, 125 insertions(+), 1 deletion(-) diff --git a/.gitignore b/.gitignore index 8282f0bf2..565d8c32f 100644 --- a/.gitignore +++ b/.gitignore @@ -16,6 +16,7 @@ coverage/ .env.test.local .env.production.local .vscode +.now npm-debug.log* yarn-debug.log* diff --git a/server/api/src/app.py b/server/api/src/app.py index 471e117bb..a0be9c166 100644 --- a/server/api/src/app.py +++ b/server/api/src/app.py @@ -34,6 +34,9 @@ '/map/heat': ( ['POST'], R.map.heat), + '/map/pins': ( + ['POST'], R.map.pins), + '/visualizations': ( ['POST'], R.visualizations), diff --git a/server/api/src/control/route_handlers.py b/server/api/src/control/route_handlers.py index dc9224083..dc3d88da0 100644 --- a/server/api/src/control/route_handlers.py +++ b/server/api/src/control/route_handlers.py @@ -55,6 +55,15 @@ async def heat(request): return json(data) + async def pins(request): + data = await map_svc.pins(**to.parse(request.json, { + 'startDate': to.req.DATE, + 'endDate': to.req.DATE, + 'requestTypes': to.opt.LIST_OF_STR, + 'ncList': to.opt.LIST_OF_INT})) + + return json(data) + async def visualizations(request): data = await vis_svc.visualizations(**to.parse(request.json, { diff --git a/server/api/src/services/map.py b/server/api/src/services/map.py index 95f05e44e..17f59f4dc 100644 --- a/server/api/src/services/map.py +++ b/server/api/src/services/map.py @@ -103,3 +103,18 @@ async def heatmap(startDate, pins = pins[fields] return pins.to_numpy() + + +async def pins(startDate, + endDate, + requestTypes=[], + ncList=[]): + + filters = { + 'startDate': startDate, + 'endDate': endDate, + 'requestTypes': requestTypes, + 'ncList': ncList} + + pins = get_pins(filters) + return pins.to_dict(orient='records') diff --git a/server/postman/collections/311-CI.postman_collection.json b/server/postman/collections/311-CI.postman_collection.json index 179833344..a05f87363 100644 --- a/server/postman/collections/311-CI.postman_collection.json +++ b/server/postman/collections/311-CI.postman_collection.json @@ -231,6 +231,54 @@ }, "response": [] }, + { + "name": "/map/pins", + "event": [ + { + "listen": "test", + "script": { + "id": "6963cb24-0804-42ee-96a9-203a65c4aee5", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"startDate\": \"2020-05-01\",\n\t\"endDate\": \"2020-06-02\",\n\t\"requestTypes\": [\"Bulky Items\", \"Graffiti Removal\", \"Dead Animal Removal\"],\n\t\"ncList\": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}/map/heat", + "host": [ + "{{base_url}}" + ], + "path": [ + "map", + "heat" + ] + } + }, + "response": [] + }, { "name": "/visualizations", "event": [ diff --git a/server/postman/collections/311-all.postman_collection.json b/server/postman/collections/311-all.postman_collection.json index 72a2dbf73..4b49a42f4 100644 --- a/server/postman/collections/311-all.postman_collection.json +++ b/server/postman/collections/311-all.postman_collection.json @@ -265,7 +265,7 @@ ], "body": { "mode": "raw", - "raw": "{\n\t\"startDate\": \"2019-01-01\",\n\t\"endDate\": \"2020-06-01\",\n\t\"requestTypes\": [\"Bulky Items\", \"Graffiti Removal\", \"Dead Animal Removal\"],\n\t\"ncList\": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20],\n\t\"zoom\": 14,\n\t\"bounds\": {\n\t\t\"north\": 90,\n\t\t\"south\": -90,\n\t\t\"west\": -180,\n\t\t\"east\": 180\n\t}\n}", + "raw": "{\n\t\"startDate\": \"2019-01-01\",\n\t\"endDate\": \"2020-06-01\",\n\t\"requestTypes\": [\"Bulky Items\", \"Graffiti Removal\", \"Dead Animal Removal\"],\n\t\"ncList\": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 20, 21, 22],\n\t\"zoom\": 14,\n\t\"bounds\": {\n\t\t\"north\": 90,\n\t\t\"south\": -90,\n\t\t\"west\": -180,\n\t\t\"east\": 180\n\t}\n}", "options": { "raw": { "language": "json" @@ -333,6 +333,54 @@ }, "response": [] }, + { + "name": "/map/pins", + "event": [ + { + "listen": "test", + "script": { + "id": "e8dbb51a-2511-4598-9676-d275e13847b5", + "exec": [ + "pm.test(\"Status code is 200\", function () {", + " pm.response.to.have.status(200);", + "});" + ], + "type": "text/javascript" + } + } + ], + "request": { + "method": "POST", + "header": [ + { + "key": "Content-Type", + "name": "Content-Type", + "value": "application/json", + "type": "text" + } + ], + "body": { + "mode": "raw", + "raw": "{\n\t\"startDate\": \"2020-05-01\",\n\t\"endDate\": \"2020-06-02\",\n\t\"requestTypes\": [\"Bulky Items\", \"Graffiti Removal\", \"Dead Animal Removal\"],\n\t\"ncList\": [4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 18, 20]\n}", + "options": { + "raw": { + "language": "json" + } + } + }, + "url": { + "raw": "{{base_url}}/map/heat", + "host": [ + "{{base_url}}" + ], + "path": [ + "map", + "heat" + ] + } + }, + "response": [] + }, { "name": "/visualizations", "event": [ From cbcc47823c1be0687b8d78de6c40fb8d64ed59e4 Mon Sep 17 00:00:00 2001 From: Jake Mensch Date: Fri, 31 Jul 2020 14:36:42 -0700 Subject: [PATCH 2/3] postman fix --- server/postman/collections/311-CI.postman_collection.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/server/postman/collections/311-CI.postman_collection.json b/server/postman/collections/311-CI.postman_collection.json index a05f87363..74e0c9788 100644 --- a/server/postman/collections/311-CI.postman_collection.json +++ b/server/postman/collections/311-CI.postman_collection.json @@ -267,13 +267,13 @@ } }, "url": { - "raw": "{{base_url}}/map/heat", + "raw": "{{base_url}}/map/pins", "host": [ "{{base_url}}" ], "path": [ "map", - "heat" + "pins" ] } }, From fb585071ce08e8f3081f8c0b263c93c42558f0c5 Mon Sep 17 00:00:00 2001 From: Jake Mensch Date: Sat, 1 Aug 2020 06:25:21 -0700 Subject: [PATCH 3/3] postman --- .../postman/collections/311-all.postman_collection.json | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/server/postman/collections/311-all.postman_collection.json b/server/postman/collections/311-all.postman_collection.json index 4b49a42f4..b45deb0b6 100644 --- a/server/postman/collections/311-all.postman_collection.json +++ b/server/postman/collections/311-all.postman_collection.json @@ -355,8 +355,8 @@ { "key": "Content-Type", "name": "Content-Type", - "value": "application/json", - "type": "text" + "type": "text", + "value": "application/json" } ], "body": { @@ -369,13 +369,13 @@ } }, "url": { - "raw": "{{base_url}}/map/heat", + "raw": "{{base_url}}/map/pins", "host": [ "{{base_url}}" ], "path": [ "map", - "heat" + "pins" ] } },