From 51257cba05562c89d5c4ec38a6bfbadca7a06ae5 Mon Sep 17 00:00:00 2001 From: sellnat77 Date: Sun, 1 Mar 2020 12:26:04 -0800 Subject: [PATCH] Added requestDetail endpoint --- server/src/app.py | 9 ++++++ server/src/services/requestDetailService.py | 32 +++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 server/src/services/requestDetailService.py diff --git a/server/src/app.py b/server/src/app.py index 4d99c34f0..47cedd430 100644 --- a/server/src/app.py +++ b/server/src/app.py @@ -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 @@ -118,6 +119,14 @@ async def pinMap(request): return json(return_data) +@app.route('/servicerequest/', 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() diff --git a/server/src/services/requestDetailService.py b/server/src/services/requestDetailService.py new file mode 100644 index 000000000..a01a20d8b --- /dev/null +++ b/server/src/services/requestDetailService.py @@ -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