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

Dev to Master #617

Merged
merged 25 commits into from
May 15, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6c4fb33
Fixed data vis error resulting from a query with zero results.
adamkendis May 7, 2020
b415a97
Merge pull request #600 from adamkendis/590-FRONT-bugFixes
jmensch1 May 8, 2020
d117590
isolated db in its own module
jmensch1 May 8, 2020
9f1cfce
added server/src to python path
jmensch1 May 9, 2020
bc8f805
removed DataService constructor and updated services that use the Dat…
jmensch1 May 10, 2020
6567fbf
updated dataservice test
jmensch1 May 10, 2020
65963ac
Merge pull request #601 from hackforla/550-BACK-PersistingDBConnections
sellnat77 May 10, 2020
db065e3
removed arg to DataService constructor in /apistatus
jmensch1 May 11, 2020
6bdc330
converted DataService to pandas
jmensch1 May 9, 2020
ad2a7fd
map and vis views
jmensch1 May 11, 2020
a9511e2
handling null fields or filters in dataservice.query
jmensch1 May 11, 2020
d89c848
Merge pull request #602 from hackforla/BACK-MaterializedViews
jmensch1 May 12, 2020
c3041b5
metadata table with last_pulled populated during ingest
jmensch1 May 11, 2020
19e3109
Merge pull request #603 from hackforla/594-BACK-LastPulledDate
sellnat77 May 12, 2020
45db20f
/visualizations and /comparison endpoints working
jmensch1 May 3, 2020
1c2bb40
frontend integration
jmensch1 May 12, 2020
f39aaa2
deleted unused endpoints and their supporting services
jmensch1 May 13, 2020
4423b5a
updated tests
jmensch1 May 13, 2020
e6d78b1
linting
jmensch1 May 13, 2020
4587ef9
Removed devcheck and basename from App and Router.
adamkendis May 13, 2020
f27ccde
Removed BASE_URL from orchestration files.
adamkendis May 13, 2020
0a676f1
minor tweaks
jmensch1 May 13, 2020
fd0277a
Merge pull request #607 from adamkendis/514-FRONT-routerFix
jmensch1 May 13, 2020
37ace7f
Merge branch 'dev' into 605-BACK-EndpointConsolidation
jmensch1 May 13, 2020
033c14c
Merge pull request #606 from hackforla/605-BACK-EndpointConsolidation
jmensch1 May 15, 2020
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: 0 additions & 1 deletion .example.env
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
REACT_APP_MAPBOX_TOKEN=REDACTED
DB_URL=REDACTED
BASE_URL=/311-data
2 changes: 0 additions & 2 deletions .github/workflows/Continuous_Delivery.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,6 @@ jobs:
run: |
echo REACT_APP_MAPBOX_TOKEN=${{ secrets.MAPBOX_TOKEN }} > .env
echo DB_URL=${{ secrets.DB_URL }} >> .env
echo BASE_URL=${{ secrets.BASE_URL }} >> .env
echo GITHUB_SHA=${{ github.sha }} >> .env
- name: Build project
run: npm run build
Expand All @@ -36,7 +35,6 @@ jobs:
ACCESS_TOKEN: ${{ secrets.ACCESS_TOKEN }}
REACT_APP_MAPBOX_TOKEN: ${{ secrets.MAPBOX_TOKEN }}
DB_URL: ${{ secrets.DB_URL }}
BASE_URL: ${{ secrets.BASE_URL }}
BASE_BRANCH: master # The branch the action should deploy from.
BRANCH: gh-pages # The branch the action should deploy to.
FOLDER: dist # The folder the action should deploy.
Expand Down
1 change: 0 additions & 1 deletion Orchestration/docker-compose-example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ services:
environment:
REACT_APP_MAPBOX_TOKEN: REDACTED
DB_URL: http://localhost:5000
BASE_URL: ''
ports:
- 3000:3000

Expand Down
1 change: 0 additions & 1 deletion copyEnv.sh
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
echo REACT_APP_MAPBOX_TOKEN=$REACT_APP_MAPBOX_TOKEN > .env
echo DB_URL=$DB_URL >> .env
echo BASE_URL=$BASE_URL >> .env
webpack
node server.js
159 changes: 32 additions & 127 deletions server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,18 @@
from datetime import datetime
from multiprocessing import cpu_count

from services.timeToCloseService import TimeToCloseService
from services.frequencyService import FrequencyService
from services.pinService import PinService
from services.pinClusterService import PinClusterService
from services.heatmapService import HeatmapService
from services.requestCountsService import RequestCountsService
from services.requestDetailService import RequestDetailService
from services.visualizationsService import VisualizationsService
from services.comparisonService import ComparisonService
from services.sqlIngest import DataHandler
from services.feedbackService import FeedbackService
from services.dataService import DataService

from utils.sanic import add_performance_header
from utils.redis import cache
from utils.database import db

app = Sanic(__name__)
CORS(app)
Expand Down Expand Up @@ -48,6 +47,7 @@ def configure_app():
if app.config['Settings']['Server']['Debug']:
add_performance_header(app)
cache.config(app.config['Settings']['Redis'])
db.config(app.config['Settings']['Database'])


@app.route('/apistatus')
Expand All @@ -61,7 +61,7 @@ async def healthcheck(request):
settings['Version']['VER_MINOR'],
settings['Version']['VER_PATCH'])

data_worker = DataService(settings)
data_worker = DataService()
lastPulled = await data_worker.lastPulled()

return json({'currentTime': currentTime,
Expand All @@ -76,82 +76,6 @@ async def index(request):
return json('You hit the index')


@app.route('/timetoclose', methods=["POST"])
@compress.compress()
async def timetoclose(request):
ttc_worker = TimeToCloseService(app.config['Settings'])

postArgs = request.json
start = postArgs.get('startDate', None)
end = postArgs.get('endDate', None)
ncs = postArgs.get('ncList', [])
requests = postArgs.get('requestTypes', [])

data = await ttc_worker.get_ttc(startDate=start,
endDate=end,
ncList=ncs,
requestTypes=requests)
return json(data)


@app.route('/timetoclose-comparison', methods=["POST"])
@compress.compress()
async def timetoclose_comparison(request):
ttc_worker = TimeToCloseService(app.config['Settings'])

postArgs = request.json
startDate = postArgs.get('startDate', None)
endDate = postArgs.get('endDate', None)
requestTypes = postArgs.get('requestTypes', [])
set1 = postArgs.get('set1', None)
set2 = postArgs.get('set2', None)

data = await ttc_worker.get_ttc_comparison(startDate=startDate,
endDate=endDate,
requestTypes=requestTypes,
set1=set1,
set2=set2)
return json(data)


@app.route('/requestfrequency', methods=["POST"])
@compress.compress()
async def requestfrequency(request):
freq_worker = FrequencyService(app.config['Settings'])

postArgs = request.json
startDate = postArgs.get('startDate', None)
endDate = postArgs.get('endDate', None)
ncList = postArgs.get('ncList', [])
requestTypes = postArgs.get('requestTypes', [])

data = await freq_worker.get_frequency(startDate=startDate,
endDate=endDate,
ncList=ncList,
requestTypes=requestTypes)
return json(data)


@app.route('/requestfrequency-comparison', methods=["POST"])
@compress.compress()
async def requestfrequency_comparison(request):
worker = FrequencyService(app.config['Settings'])

postArgs = request.json
startDate = postArgs.get('startDate', None)
endDate = postArgs.get('endDate', None)
requestTypes = postArgs.get('requestTypes', [])
set1 = postArgs.get('set1', None)
set2 = postArgs.get('set2', None)

data = await worker.get_frequency_comparison(startDate=startDate,
endDate=endDate,
requestTypes=requestTypes,
set1=set1,
set2=set2)
return json(data)


@app.route('/ingest', methods=["GET"])
@compress.compress()
async def ingest(request):
Expand Down Expand Up @@ -209,23 +133,6 @@ async def ingest(request):
return json(data)


@app.route('/pins', methods=["POST"])
@compress.compress()
async def pinMap(request):
pin_worker = PinService(app.config['Settings'])
postArgs = request.json
start = postArgs.get('startDate', '2015-01-01')
end = postArgs.get('endDate', '2015-12-31 01:01:01')
ncs = postArgs.get('ncList', ['SHERMAN OAKS NC'])
requests = postArgs.get('requestTypes', ['Bulky Items'])

return_data = await pin_worker.get_base_pins(startDate=start,
endDate=end,
ncList=ncs,
requestTypes=requests)
return json(return_data)


@app.route('/pin-clusters', methods=["POST"])
@compress.compress()
async def pinClusters(request):
Expand Down Expand Up @@ -263,53 +170,51 @@ async def heatmap(request):
return json(heatmap)


@app.route('/requestcounts', methods=["POST"])
@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('/visualizations', methods=["POST"])
@compress.compress()
async def requestCounts(request):
counts_worker = RequestCountsService(app.config['Settings'])
async def visualizations(request):
worker = VisualizationsService()

postArgs = request.json
start = postArgs.get('startDate', None)
end = postArgs.get('endDate', None)
ncs = postArgs.get('ncList', [])
requests = postArgs.get('requestTypes', [])
countFields = postArgs.get('countFields', [])

return_data = await counts_worker.get_req_counts(startDate=start,
endDate=end,
ncList=ncs,
requestTypes=requests,
countFields=countFields)
return json(return_data)
data = await worker.visualizations(startDate=start,
endDate=end,
requestTypes=requests,
ncList=ncs)
return json(data)


@app.route('/requestcounts-comparison', methods=["POST"])
@app.route('/comparison/<type>', methods=["POST"])
@compress.compress()
async def requestCountsComparison(request):
worker = RequestCountsService(app.config['Settings'])
async def comparison(request, type):
worker = ComparisonService()

postArgs = request.json
startDate = postArgs.get('startDate', None)
endDate = postArgs.get('endDate', None)
requestTypes = postArgs.get('requestTypes', [])
set1 = postArgs.get('set1', None)
set2 = postArgs.get('set2', None)
countFields = postArgs.get('countFields', [])

data = await worker.get_req_counts_comparison(startDate=startDate,
endDate=endDate,
requestTypes=requestTypes,
set1=set1,
set2=set2,
countFields=countFields)
return json(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)
data = await worker.comparison(type=type,
startDate=startDate,
endDate=endDate,
requestTypes=requestTypes,
set1=set1,
set2=set2)
return json(data)


@app.route('/feedback', methods=["POST"])
Expand Down
Loading