Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

/map/pins endpoint #762

Merged
merged 3 commits into from
Aug 1, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ coverage/
.env.test.local
.env.production.local
.vscode
.now

npm-debug.log*
yarn-debug.log*
Expand Down
3 changes: 3 additions & 0 deletions server/api/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@
'/map/heat': (
['POST'], R.map.heat),

'/map/pins': (
['POST'], R.map.pins),

'/visualizations': (
['POST'], R.visualizations),

Expand Down
9 changes: 9 additions & 0 deletions server/api/src/control/route_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -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, {
Expand Down
15 changes: 15 additions & 0 deletions server/api/src/services/map.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
48 changes: 48 additions & 0 deletions server/postman/collections/311-CI.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/pins",
"host": [
"{{base_url}}"
],
"path": [
"map",
"pins"
]
}
},
"response": []
},
{
"name": "/visualizations",
"event": [
Expand Down
50 changes: 49 additions & 1 deletion server/postman/collections/311-all.postman_collection.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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",
"type": "text",
"value": "application/json"
}
],
"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/pins",
"host": [
"{{base_url}}"
],
"path": [
"map",
"pins"
]
}
},
"response": []
},
{
"name": "/visualizations",
"event": [
Expand Down