Skip to content

Commit

Permalink
Merge pull request #762 from hackforla/BACK-PinsEndpoint
Browse files Browse the repository at this point in the history
/map/pins endpoint
  • Loading branch information
jmensch1 authored Aug 1, 2020
2 parents 1495013 + fb58507 commit 25e05f9
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 1 deletion.
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

0 comments on commit 25e05f9

Please sign in to comment.