Skip to content

Commit

Permalink
Merge pull request #522 from hackforla/dev
Browse files Browse the repository at this point in the history
Release update
  • Loading branch information
brodly authored Apr 10, 2020
2 parents d4caaab + f4771e9 commit dc818f1
Show file tree
Hide file tree
Showing 30 changed files with 698 additions and 117 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/Publish_Backend_Package.yml
Original file line number Diff line number Diff line change
Expand Up @@ -47,4 +47,4 @@ jobs:
env:
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
run: |
heroku config:set -a hackforla-311 PROJECT_URL=${{ secrets.PROJECT_URL }} GITHUB_TOKEN=${{ secrets.GH_ISSUES_TOKEN }} TOKEN=${{ secrets.SOCRATA_TOKEN }}
heroku config:set -a hackforla-311 PROJECT_URL=${{ secrets.PROJECT_URL }} GITHUB_TOKEN=${{ secrets.GH_ISSUES_TOKEN }} TOKEN=${{ secrets.SOCRATA_TOKEN }} GITHUB_SHA=${{ github.sha }}
8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,16 +58,16 @@
"devDependencies": {
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.7.0",
"@babel/preset-env": "^7.8.4",
"@babel/preset-env": "^7.9.5",
"@babel/preset-react": "^7.8.3",
"babel-eslint": "^10.0.3",
"babel-eslint": "^10.1.0",
"babel-loader": "^8.0.6",
"css-loader": "^3.2.0",
"css-loader": "^3.5.1",
"enzyme": "^3.10.0",
"enzyme-adapter-react-16": "^1.15.1",
"eslint": "^6.7.2",
"eslint-config-airbnb": "^18.0.1",
"eslint-plugin-import": "^2.19.1",
"eslint-plugin-import": "^2.20.2",
"eslint-plugin-jsx-a11y": "^6.2.3",
"eslint-plugin-react": "^7.17.0",
"eslint-plugin-react-hooks": "^1.7.0",
Expand Down
18 changes: 9 additions & 9 deletions server/src/services/feedbackService.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,18 +43,18 @@ async def create_issue(self,
response = await session.post(self.issues_url,
data=payload,
headers=headers)
response.raise_for_status()
response_content = loads(response.content)
issue_id = response_content['id']
response.raise_for_status()
return issue_id
except requests.exceptions.HTTPError as errh:
return "An Http Error occurred:" + repr(errh)
return errh
except requests.exceptions.ConnectionError as errc:
return "An Error Connecting to the API occurred:" + repr(errc)
return errc
except requests.exceptions.Timeout as errt:
return "A Timeout Error occurred:" + repr(errt)
return errt
except requests.exceptions.RequestException as err:
return "An Unknown Error occurred" + repr(err)
return err

async def add_issue_to_project(self, issue_id, content_type='Issue'):
"""
Expand Down Expand Up @@ -83,10 +83,10 @@ async def add_issue_to_project(self, issue_id, content_type='Issue'):
response.raise_for_status()
return response.status_code
except requests.exceptions.HTTPError as errh:
return "An Http Error occurred:" + repr(errh)
return errh
except requests.exceptions.ConnectionError as errc:
return "An Error Connecting to the API occurred:" + repr(errc)
return errc
except requests.exceptions.Timeout as errt:
return "A Timeout Error occurred:" + repr(errt)
return errt
except requests.exceptions.RequestException as err:
return "An Unknown Error occurred" + repr(err)
return err
Binary file added src/assets/contact_bg.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
40 changes: 22 additions & 18 deletions src/components/Comparison/FrequencyComparison.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import React from 'react';
import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import moment from 'moment';
import { DISTRICT_TYPES } from '@components/common/CONSTANTS';
import { DISTRICT_TYPES, COMPARISON_SETS } from '@components/common/CONSTANTS';
import Chart from '@components/Chart';
import ChartExportSelect from '@components/export/ChartExportSelect';

const FrequencyComparison = ({
bins,
set1,
set2,
sets,
}) => {
/* /// DATA /// */

const getDataSet = set => {
const { district, counts } = set;
const getDataSet = setId => {
const { district, counts } = sets[setId];

const totals = Array.from({ length: bins.length - 1 }).map((_, idx) => (
Object.keys(counts).reduce((acc, name) => (
acc + counts[name][idx]
), 0)
));

const color = DISTRICT_TYPES.find(t => t.id === district)?.color;
const label = DISTRICT_TYPES.find(t => t.id === district)?.name;
const { color, name: setName } = COMPARISON_SETS[setId];
const label = DISTRICT_TYPES.find(t => t.id === district)?.name
.replace(' District', ` (${setName})`);

return {
data: totals,
Expand All @@ -38,8 +38,8 @@ const FrequencyComparison = ({
const chartData = {
labels: bins.slice(0, -1).map(bin => moment(bin).format('MMM D')),
datasets: [
getDataSet(set1),
getDataSet(set2),
getDataSet('set1'),
getDataSet('set2'),
],
};

Expand Down Expand Up @@ -108,20 +108,24 @@ const FrequencyComparison = ({

const mapStateToProps = state => ({
bins: state.comparisonData.frequency.bins,
set1: state.comparisonData.frequency.set1,
set2: state.comparisonData.frequency.set2,
sets: {
set1: state.comparisonData.frequency.set1,
set2: state.comparisonData.frequency.set2,
},
});

export default connect(mapStateToProps)(FrequencyComparison);

FrequencyComparison.propTypes = {
bins: PropTypes.arrayOf(PropTypes.string).isRequired,
set1: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}).isRequired,
}).isRequired,
set2: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}).isRequired,
sets: PropTypes.shape({
set1: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}),
}),
set2: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}),
}),
}).isRequired,
};
24 changes: 10 additions & 14 deletions src/components/Comparison/TimeToCloseComparison.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,37 +2,33 @@ import React from 'react';
import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import Chart, { ChartTooltip as Tooltip } from '@components/Chart';
import { DISTRICT_TYPES, COUNCILS } from '@components/common/CONSTANTS';
import { COUNCILS, COMPARISON_SETS } from '@components/common/CONSTANTS';
import ChartExportSelect from '@components/export/ChartExportSelect';

const TimeToCloseComparison = ({
timeToClose: { set1, set2 },
timeToClose,
}) => {
/* /// DATA /// */

const boxColors = {
nc: DISTRICT_TYPES.find(t => t.id === 'nc')?.color,
cc: DISTRICT_TYPES.find(t => t.id === 'cc')?.color,
};

const boxLabels = {
nc: id => COUNCILS.find(c => parseInt(id, 10) === c.id).name,
cc: name => `District ${name}`,
};

const getBoxes = ({ district, data }) => (
Object.keys(data)
const getBoxes = setId => {
const { district, data } = timeToClose[setId];
return Object.keys(data)
.filter(name => data[name].count !== 0)
.map(name => ({
label: boxLabels[district](name),
color: boxColors[district],
color: COMPARISON_SETS[setId].color,
stats: { ...data[name], outliers: [] },
}))
);
}));
};

const boxes = [
...getBoxes(set1),
...getBoxes(set2),
...getBoxes('set1'),
...getBoxes('set2'),
];

const chartData = {
Expand Down
40 changes: 22 additions & 18 deletions src/components/Comparison/TotalRequestsComparison.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,28 @@ import React from 'react';
import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import moment from 'moment';
import { DISTRICT_TYPES } from '@components/common/CONSTANTS';
import { DISTRICT_TYPES, COMPARISON_SETS } from '@components/common/CONSTANTS';
import Chart from '@components/Chart';
import ChartExportSelect from '@components/export/ChartExportSelect';

const TotalRequestsComparison = ({
bins,
set1,
set2,
sets,
}) => {
/* /// DATA /// */

const getDataSet = set => {
const { district, counts } = set;
const getDataSet = setId => {
const { district, counts } = sets[setId];

const totals = Array.from({ length: bins.length - 1 }).map((_, idx) => (
Object.keys(counts).reduce((acc, name) => (
acc + counts[name][idx]
), 0)
));

const color = DISTRICT_TYPES.find(t => t.id === district)?.color;
const label = DISTRICT_TYPES.find(t => t.id === district)?.name;
const { color, name: setName } = COMPARISON_SETS[setId];
const label = DISTRICT_TYPES.find(t => t.id === district)?.name
.replace(' District', ` (${setName})`);

return {
data: totals,
Expand All @@ -38,8 +38,8 @@ const TotalRequestsComparison = ({
const chartData = {
labels: bins.slice(0, -1).map(bin => moment(bin).format('MMM D')),
datasets: [
getDataSet(set1),
getDataSet(set2),
getDataSet('set1'),
getDataSet('set2'),
],
};

Expand Down Expand Up @@ -108,20 +108,24 @@ const TotalRequestsComparison = ({

const mapStateToProps = state => ({
bins: state.comparisonData.frequency.bins,
set1: state.comparisonData.frequency.set1,
set2: state.comparisonData.frequency.set2,
sets: {
set1: state.comparisonData.frequency.set1,
set2: state.comparisonData.frequency.set2,
},
});

export default connect(mapStateToProps)(TotalRequestsComparison);

TotalRequestsComparison.propTypes = {
bins: PropTypes.arrayOf(PropTypes.string).isRequired,
set1: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}).isRequired,
}).isRequired,
set2: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}).isRequired,
sets: PropTypes.shape({
set1: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}),
}),
set2: PropTypes.shape({
district: PropTypes.string,
counts: PropTypes.shape({}),
}),
}).isRequired,
};
11 changes: 11 additions & 0 deletions src/components/PinMap/PinMap.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -296,6 +296,17 @@ class PinMap extends Component {
if (link) link.click();
}}
/>
<div className="heatmap-legend-wrapper has-text-centered">
Concentration of Reports (Heatmap)
<div id="heatmap-gradient-legend" className="level">
<span className="level-left">
Low
</span>
<span className="level-right">
High
</span>
</div>
</div>
</>
);
}
Expand Down
39 changes: 24 additions & 15 deletions src/components/chartExtras/ComparisonCriteria.jsx
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import React from 'react';
import PropTypes from 'proptypes';
import { connect } from 'react-redux';
import { DISTRICT_TYPES, REQUEST_TYPES } from '@components/common/CONSTANTS';
import { DISTRICT_TYPES, REQUEST_TYPES, COMPARISON_SETS } from '@components/common/CONSTANTS';
import CollapsibleList from '@components/common/CollapsibleList';

const ComparisonCriteria = ({
startDate,
endDate,
set1,
set2,
sets,
requestTypes,
}) => {
// DATES //
Expand All @@ -17,7 +16,9 @@ const ComparisonCriteria = ({
: 'No date range selected.';

// DISTRICTS //
const districtSelection = set => {
const districtSelection = setId => {
const set = sets[setId];

if (!set.district) {
return (
<>
Expand All @@ -30,10 +31,14 @@ const ComparisonCriteria = ({
}

const { name } = DISTRICT_TYPES.find(t => set.district === t.id);
const { name: setName } = COMPARISON_SETS[setId];
return (
<>
<span className="criteria-type">
{ name }
&nbsp;(
{ setName }
)
</span>
<CollapsibleList
items={set.list}
Expand Down Expand Up @@ -78,8 +83,8 @@ const ComparisonCriteria = ({
Date Range
</span>
{ dateText }
{ districtSelection(set1) }
{ districtSelection(set2) }
{ districtSelection('set1') }
{ districtSelection('set2') }
<span className="criteria-type">
Request Type Selection
</span>
Expand All @@ -92,8 +97,10 @@ const ComparisonCriteria = ({
const mapStateToProps = state => ({
startDate: state.comparisonFilters.startDate,
endDate: state.comparisonFilters.endDate,
set1: state.comparisonFilters.comparison.set1,
set2: state.comparisonFilters.comparison.set2,
sets: {
set1: state.comparisonFilters.comparison.set1,
set2: state.comparisonFilters.comparison.set2,
},
requestTypes: state.comparisonFilters.requestTypes,
});

Expand All @@ -102,13 +109,15 @@ export default connect(mapStateToProps)(ComparisonCriteria);
ComparisonCriteria.propTypes = {
startDate: PropTypes.string,
endDate: PropTypes.string,
set1: PropTypes.shape({
district: PropTypes.string,
list: PropTypes.arrayOf(PropTypes.string),
}).isRequired,
set2: PropTypes.shape({
district: PropTypes.string,
list: PropTypes.arrayOf(PropTypes.string),
sets: PropTypes.shape({
set1: PropTypes.shape({
district: PropTypes.string,
list: PropTypes.array,
}),
set2: PropTypes.shape({
district: PropTypes.string,
list: PropTypes.array,
}),
}).isRequired,
requestTypes: PropTypes.shape({}).isRequired,
};
Expand Down
Loading

0 comments on commit dc818f1

Please sign in to comment.