From a142b565e4166ada26ffc5874dbe9a5d092e93a9 Mon Sep 17 00:00:00 2001 From: Jeremia Kimelman Date: Fri, 16 Jun 2017 15:54:05 -0400 Subject: [PATCH 1/4] Use "No assigned county" in search results Refs https://github.com/18F/crime-data-explorer/issues/175 --- src/components/AgencySearchResults.js | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/components/AgencySearchResults.js b/src/components/AgencySearchResults.js index 3a110649..c255a041 100644 --- a/src/components/AgencySearchResults.js +++ b/src/components/AgencySearchResults.js @@ -30,7 +30,7 @@ const AgencySearchResults = ({ data, groupKey, groupValues, onClick }) => { data: noFederal.filter(d => d[groupKey] === key), })) dataGrouped.push({ - key: 'Unspecified', + key: 'No assigned county', data: noFederal.filter(d => d[groupKey] === null), }) @@ -41,19 +41,19 @@ const AgencySearchResults = ({ data, groupKey, groupValues, onClick }) => { >
Results
{noFederal.length === 0 &&
No results
} - {dataGrouped.filter(g => g.data.length > 0).map(g => + {dataGrouped.filter(g => g.data.length > 0).map(g => (
{g.key}
-
, - )} + + ))} ) } From 355914973dd2637d9c809f714735d9fe80e28554 Mon Sep 17 00:00:00 2001 From: Jeremia Kimelman Date: Fri, 16 Jun 2017 15:56:10 -0400 Subject: [PATCH 2/4] Remove second place thumbnail --- src/containers/ExplorerHeaderContainer.js | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/src/containers/ExplorerHeaderContainer.js b/src/containers/ExplorerHeaderContainer.js index 0e97ac00..8ff2f219 100644 --- a/src/containers/ExplorerHeaderContainer.js +++ b/src/containers/ExplorerHeaderContainer.js @@ -51,20 +51,10 @@ const ExplorerHeaderContainer = ({
- {isAgency + {isAgency && !isLoading ? `${placeDisplay}, ${startCase(usState)}` : startCase(usState)}
- - {isAgency && - !isLoading && -
- - {agency.agency_name} -
}
From 00ca638d985d88dcee0a4b41f6536a0756aa953d Mon Sep 17 00:00:00 2001 From: Jeremia Kimelman Date: Fri, 16 Jun 2017 16:13:54 -0400 Subject: [PATCH 3/4] Add glossary term for crime type in intro text for nation and states --- src/components/ExplorerIntroNational.js | 26 +++++++++++++++++++------ src/components/ExplorerIntroState.js | 24 ++++++++++++++++++----- 2 files changed, 39 insertions(+), 11 deletions(-) diff --git a/src/components/ExplorerIntroNational.js b/src/components/ExplorerIntroNational.js index 37fd5089..fc6c842e 100644 --- a/src/components/ExplorerIntroNational.js +++ b/src/components/ExplorerIntroNational.js @@ -1,19 +1,28 @@ +import lowerCase from 'lodash.lowercase' +import upperFirst from 'lodash.upperfirst' import PropTypes from 'prop-types' import React from 'react' +import Term from './Term' import { estimatedTerm, nibrsTerm, srsTerm } from './Terms' import { formatNum } from '../util/formats' +import mapCrimeToGlossaryTerm from '../util/glossary' const ExplorerIntroNational = ({ crime, ucr, until }) => { const isArson = crime === 'arson' const untilUcr = ucr.find(p => p.year === until) + const crimeTerm = ( + + {upperFirst(lowerCase(crime))} + + ) return (
{!isArson ?

- Crime rates for the nation are derived from both + {crimeTerm} rates for the nation are derived from both {' '} {srsTerm} {' '} @@ -21,7 +30,7 @@ const ExplorerIntroNational = ({ crime, ucr, until }) => { {' '} {nibrsTerm} {' '} - reports sent to the FBI. + reports voluntarily submitted to the FBI.

In @@ -31,10 +40,15 @@ const ExplorerIntroNational = ({ crime, ucr, until }) => { {' '} {estimatedTerm} {' '} - crime statistics for the nation - based on data voluntarily reported by{' '} - {formatNum(untilUcr.participating_agencies)}{' '} - law enforcement agencies. + crime statistics for the nation based on data received from + {' '} + {formatNum(untilUcr.participating_agencies)} + {' '} + law enforcement agencies out of + {' '} + {formatNum(untilUcr.total_agencies)} + {' '} + in the country that year.

:
diff --git a/src/components/ExplorerIntroState.js b/src/components/ExplorerIntroState.js index 3d507b10..4cc39cbc 100644 --- a/src/components/ExplorerIntroState.js +++ b/src/components/ExplorerIntroState.js @@ -1,34 +1,44 @@ +import lowerCase from 'lodash.lowercase' import startCase from 'lodash.startcase' +import upperFirst from 'lodash.upperfirst' import React from 'react' +import Term from './Term' import { estimatedTerm, nibrsTerm, srsTerm } from './Terms' import { formatNum } from '../util/formats' +import mapCrimeToGlossaryTerm from '../util/glossary' import ucrParticipationLookup from '../util/ucr' -const getReportTerms = ({ nibrs, srs, hybrid }) => +const getReportTerms = ({ nibrs, srs, hybrid }) => ( {hybrid && 'both '} {srs && srsTerm} {hybrid && ' and '} {nibrs && nibrsTerm} +) const ExplorerIntroState = ({ crime, place, ucr, until }) => { const isArson = crime === 'arson' const { nibrs, srs } = ucrParticipationLookup(place) const untilUcr = ucr.find(p => p.year === until) const reportTerms = getReportTerms({ nibrs, srs, hybrid: nibrs && srs }) + const crimeTerm = ( + + {upperFirst(lowerCase(crime))} + + ) return (
{!isArson ?

- Crime rates for {startCase(place)} are derived from + {crimeTerm} rates for {startCase(place)} are derived from {' '} {reportTerms} {' '} - reports sent to the FBI. + reports voluntarily submitted to the FBI.

In @@ -38,11 +48,15 @@ const ExplorerIntroState = ({ crime, place, ucr, until }) => { {' '} {startCase(place)} {' '} - based on data voluntarily reported by + based on data received from {' '} {formatNum(untilUcr.participating_agencies)} {' '} - law enforcement agencies. + law enforcement agencies out of + {' '} + {formatNum(untilUcr.total_agencies)} + {' '} + in the state that year.

:
From a045241e217659cdf5ef34f6db0d32f51db77c9c Mon Sep 17 00:00:00 2001 From: Jeremia Kimelman Date: Fri, 16 Jun 2017 16:53:53 -0400 Subject: [PATCH 4/4] Rerun prettier --- src/components/AgencySearchResults.js | 12 ++++++------ src/components/ExplorerIntroState.js | 3 +-- src/components/NibrsStackedBarDetails.js | 3 +-- src/containers/NibrsContainer.js | 14 +++++++------- 4 files changed, 15 insertions(+), 17 deletions(-) diff --git a/src/components/AgencySearchResults.js b/src/components/AgencySearchResults.js index c255a041..c135a6a9 100644 --- a/src/components/AgencySearchResults.js +++ b/src/components/AgencySearchResults.js @@ -41,19 +41,19 @@ const AgencySearchResults = ({ data, groupKey, groupValues, onClick }) => { >
Results
{noFederal.length === 0 &&
No results
} - {dataGrouped.filter(g => g.data.length > 0).map(g => ( + {dataGrouped.filter(g => g.data.length > 0).map(g =>
{g.key}
    {g.data .slice(0, 100) .sort((a, b) => a.agency_name < b.agency_name) - .map((d, i) => ( - - ))} + .map((d, i) => + , + )}
-
- ))} +
, + )}
) } diff --git a/src/components/ExplorerIntroState.js b/src/components/ExplorerIntroState.js index 4cc39cbc..e07f9066 100644 --- a/src/components/ExplorerIntroState.js +++ b/src/components/ExplorerIntroState.js @@ -9,14 +9,13 @@ import { formatNum } from '../util/formats' import mapCrimeToGlossaryTerm from '../util/glossary' import ucrParticipationLookup from '../util/ucr' -const getReportTerms = ({ nibrs, srs, hybrid }) => ( +const getReportTerms = ({ nibrs, srs, hybrid }) => {hybrid && 'both '} {srs && srsTerm} {hybrid && ' and '} {nibrs && nibrsTerm} -) const ExplorerIntroState = ({ crime, place, ucr, until }) => { const isArson = crime === 'arson' diff --git a/src/components/NibrsStackedBarDetails.js b/src/components/NibrsStackedBarDetails.js index 1f33c479..b613ca78 100644 --- a/src/components/NibrsStackedBarDetails.js +++ b/src/components/NibrsStackedBarDetails.js @@ -4,7 +4,7 @@ import React from 'react' const fmt = p => (p > 0.01 ? format('.0%')(p) : '<1%') -const NibrsStackedBarDetails = ({ colorMap, data, total }) => ( +const NibrsStackedBarDetails = ({ colorMap, data, total }) =>
    {data.map((d, i) => { const notLast = i + 1 !== data.length ? 'mb1' : '' @@ -25,7 +25,6 @@ const NibrsStackedBarDetails = ({ colorMap, data, total }) => ( ) })}
-) NibrsStackedBarDetails.propTypes = { colorMap: PropTypes.func.isRequired, diff --git a/src/containers/NibrsContainer.js b/src/containers/NibrsContainer.js index f9122a0d..4f72e0e4 100644 --- a/src/containers/NibrsContainer.js +++ b/src/containers/NibrsContainer.js @@ -11,9 +11,7 @@ import { nibrsTerm } from '../components/Terms' import parseNibrs from '../util/nibrs' import { getAgency, oriToState } from '../util/ori' import { getPlaceInfo } from '../util/place' -import ucrParticipation, { - shouldFetchNibrs as shouldShowNibrs, -} from '../util/ucr' +import ucrParticipation, { shouldFetchNibrs as shouldShowNibrs } from '../util/ucr' const fbiLink = 'https://ucr.fbi.gov/ucr-program-data-collections' const formatNumber = format(',') @@ -70,10 +68,12 @@ const NibrsContainer = ({ totalCount = filteredData.offenderRaceCode.reduce((a, b) => a + b.count, 0) content = (
- {dataParsed.map((d, i) => ( + {dataParsed.map((d, i) =>
-
- ))} +
, + )}
) } else if (error) {