Skip to content

Commit

Permalink
Merge pull request #458 from hackforla/dev
Browse files Browse the repository at this point in the history
Release update
  • Loading branch information
sellnat77 authored Mar 25, 2020
2 parents b03a5f8 + 68f5fee commit d191dcd
Show file tree
Hide file tree
Showing 48 changed files with 1,768 additions and 668 deletions.
5 changes: 4 additions & 1 deletion .github/workflows/Terraform_Checks.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
name: 'Terraform Checks'
on: [pull_request]
on:
pull_request:
branches-ignore:
- '**'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
tf_version: 'latest'
Expand Down
3 changes: 3 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"version": "0.1.0",
"homepage": "https://hackforla.github.io/311-data",
"dependencies": {
"@react-pdf/renderer": "^1.6.8",
"axios": "^0.19.0",
"babel-jest": "^24.9.0",
"bulma": "^0.8.0",
Expand All @@ -18,6 +19,7 @@
"eslint-import-resolver-webpack": "^0.12.1",
"gh-pages": "^2.1.1",
"html-webpack-plugin": "^3.2.0",
"html2canvas": "^1.0.0-rc.5",
"jest": "^24.9.0",
"leaflet": "^1.5.1",
"leaflet.markercluster": "^1.4.1",
Expand All @@ -28,6 +30,7 @@
"react-dom": "^16.8.6",
"react-leaflet": "^2.4.0",
"react-leaflet-choropleth": "^2.0.0",
"react-leaflet-easyprint": "^2.0.0",
"react-leaflet-heatmap-layer": "^2.0.0",
"react-leaflet-markercluster": "^2.0.0-rc3",
"react-redux": "^7.1.3",
Expand Down
1 change: 0 additions & 1 deletion public/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
<link rel="stylesheet" href="https://unpkg.com/[email protected]/dist/leaflet.css"
integrity="sha512-xwE/Az9zrjBIphAcBb3F6JVqxf46+CDLwfLMHloNu6KEQCAWi6HcDUbeOfBIptF7tcCzusKFjFw2yuvEpDL9wQ=="
crossorigin=""/>
<link rel="stylesheet" href="https://unpkg.com/react-leaflet-markercluster/dist/styles.min.css" />
<link href="https://fonts.googleapis.com/css?family=Open+Sans:700|Roboto&display=swap" rel="stylesheet">
<title>311 Data</title>
</head>
Expand Down
30 changes: 18 additions & 12 deletions server/src/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@
from datetime import datetime
from multiprocessing import cpu_count

from services.time_to_close import time_to_close
from services.frequency import frequency
from services.timeToCloseService import TimeToCloseService
from services.frequencyService import FrequencyService
from services.pinService import PinService
from services.requestCountsService import RequestCountsService
from services.requestDetailService import RequestDetailService
Expand Down Expand Up @@ -53,30 +53,36 @@ async def index(request):
@app.route('/timetoclose', methods=["POST"])
@compress.compress()
async def timetoclose(request):
ttc_worker = time_to_close(app.config['Settings'])
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 = ttc_worker.ttc(startDate=start,
endDate=end,
ncList=ncs,
requestTypes=requests)
data = await ttc_worker.get_ttc(startDate=start,
endDate=end,
ncList=ncs,
requestTypes=requests)
return json(data)


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

data = freq_worker.freq_view_data(service=True,
councils=[],
aggregate=True)
postArgs = request.json
start = postArgs.get('startDate', None)
end = postArgs.get('endDate', None)
ncs = postArgs.get('ncList', [])
requests = postArgs.get('requestTypes', [])

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


Expand Down
21 changes: 15 additions & 6 deletions server/src/services/dataService.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def __init__(self, config=None, tableName="ingest_staging_table"):
self.table = tableName
self.data = None
self.engine = db.create_engine(self.dbString)
self.session = sessionmaker(bind=self.engine)()
self.Session = sessionmaker(bind=self.engine)

def standardFilters(self,
startDate=None,
Expand All @@ -54,10 +54,16 @@ def itemQuery(self, requestNumber):
if not requestNumber or not isinstance(requestNumber, str):
return {'Error': 'Missing request number'}

return self.session \
session = self.Session()
record = session \
.query(Request) \
.get(requestNumber) \
._asdict()
.get(requestNumber)
session.close()

if record:
return record._asdict()
else:
return {'Error': 'Request number not found'}

@includeMeta
def query(self, queryItems=[], queryFilters=[], limit=None):
Expand All @@ -70,11 +76,14 @@ def query(self, queryItems=[], queryFilters=[], limit=None):
return {'Error': 'Missing query items'}

selectFields = [getattr(Request, item) for item in queryItems]
records = self.session \

session = self.Session()
records = session \
.query(*selectFields) \
.filter(*queryFilters) \
.limit(limit) \
.all()
session.close()

return [rec._asdict() for rec in records]

Expand All @@ -94,7 +103,7 @@ def aggregateQuery(self, countFields=[], queryFilters=[]):
return [{
'field': field,
'counts': df.groupby(by=field).size().to_dict()
} for field in countFields]
} for field in countFields if field in df.columns]

def storedProc(self):
pass
133 changes: 0 additions & 133 deletions server/src/services/frequency.py

This file was deleted.

Loading

0 comments on commit d191dcd

Please sign in to comment.