Skip to content

Commit

Permalink
Merge pull request #327 from hackforla/324_BACK_ReqDetail
Browse files Browse the repository at this point in the history
Added requestDetail endpoint
  • Loading branch information
sellnat77 authored Mar 1, 2020
2 parents 2abd169 + 7dd620f commit 3fac0a1
Show file tree
Hide file tree
Showing 2 changed files with 41 additions and 0 deletions.
9 changes: 9 additions & 0 deletions server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from services.time_to_close import time_to_close
from services.frequency import frequency
from services.pinService import PinService
from services.requestDetailService import RequestDetailService
from services.ingress_service import ingress_service
from services.sqlIngest import DataHandler

Expand Down Expand Up @@ -118,6 +119,14 @@ async def pinMap(request):
return json(return_data)


@app.route('/servicerequest/<srnumber>', methods=["GET"])
async def requestDetails(request, srnumber):
detail_worker = RequestDetailService(app.config['Settings'])

return_data = await detail_worker.get_request_detail(srnumber)
return json(return_data)


@app.route('/test_multiple_workers')
async def test_multiple_workers(request):
Timer(10.0, print, ["Timer Test."]).start()
Expand Down
32 changes: 32 additions & 0 deletions server/src/services/requestDetailService.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
from .dataService import DataService


class RequestDetailService(object):
def __init__(self, config=None, tableName="ingest_staging_table"):
self.dataAccess = DataService(config, tableName)

async def get_request_detail(self, requestNumber=None):
"""
Returns all properties tied to a service request given the srNumber
{
'LastPulled': 'Timestamp',
'data': {
'ncname':'String',
'requesttype':'String',
'srnumber':'String',
'latitude': 'String',
'longitude': 'String',
'address': 'String',
'createddate': 'Timestamp'
.
.
.
}
}
"""

items = ['*']
filters = ['srnumber = \'{}\''.format(requestNumber)]
result = self.dataAccess.query(items, filters)

return result

0 comments on commit 3fac0a1

Please sign in to comment.