Skip to content

Commit

Permalink
Exclude probation from PA racial disparities narrative (#420)
Browse files Browse the repository at this point in the history
  • Loading branch information
macfarlandian committed May 7, 2021
1 parent 26d09f1 commit 218ed17
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 21 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,9 @@ import { observer } from "mobx-react-lite";
import React from "react";
import RacialDisparitiesNarrative, {
SupervisionType,
SupervisionTypeList,
} from "../contentModels/RacialDisparitiesNarrative";
import { Dropdown } from "../UiLibrary";

const DROPDOWN_OPTIONS = SupervisionTypeList.map((id) => ({
id,
label: `${id === "supervision" ? "All " : ""}${capitalCase(id)}`,
}));

type SupervisionTypeFilterSelectProps = {
narrative: RacialDisparitiesNarrative;
};
Expand All @@ -46,11 +40,16 @@ const SupervisionTypeFilterSelect: React.FC<SupervisionTypeFilterSelectProps> =
}
);

const options = narrative.supervisionTypeList.map((id) => ({
id,
label: `${id === "supervision" ? "All " : ""}${capitalCase(id)}`,
}));

return (
<Dropdown
label="Supervision Type"
onChange={onChange}
options={DROPDOWN_OPTIONS}
options={options}
selectedId={narrative.supervisionType}
/>
);
Expand Down
8 changes: 4 additions & 4 deletions spotlight-client/src/contentApi/sources/us_pa.ts
Original file line number Diff line number Diff line change
Expand Up @@ -336,6 +336,7 @@ const content: TenantContent = {
supervisionPopulation: "All people under supervision",
totalPopulationSentences: "All people sentenced and under DOC control",
},
supervisionTypes: ["parole"],
sections: {
beforeCorrections: {
title: "Disparities are already present before incarceration",
Expand Down Expand Up @@ -375,21 +376,20 @@ const content: TenantContent = {
supervision: {
title: "How can community supervision impact disparities?",
body: `<p>
For individuals on probation (community supervision in lieu of a prison
sentence) or on parole, failure can mean revocation: a process that removes
For individuals on parole, failure can mean revocation: a process that removes
people from community supervision and places them in prison.
</p>
<p>
{ethnonymCapitalized} represent {supervision.populationProportion36Mo} of the
{supervisionType} population, but were {supervision.revocationProportion36Mo}
parole population, but were {supervision.revocationProportion36Mo}
of revocation admissions to prison in the last 3 years.
</p>
<p>
Reasons for a revocation can vary: {ethnonym} are revoked
{supervision.technicalProportion36Mo} of the time for technical violations (a
rule of supervision, rather than a crime),
{supervision.absconsionProportion36Mo} of the time for absconsion from
{supervisionType}, and {supervision.newCrimeProportion36Mo} of the time for
parole, and {supervision.newCrimeProportion36Mo} of the time for
new crimes. In contrast, overall revocations for technical violations are
{supervision.overall.technicalProportion36Mo}, revocations for absconsion
{supervision.overall.absconsionProportion36Mo} and revocations for new crime
Expand Down
2 changes: 2 additions & 0 deletions spotlight-client/src/contentApi/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
// =============================================================================

import type { Topology } from "topojson-specification";
import { SupervisionType } from "../contentModels/RacialDisparitiesNarrative";
import { AgeValue, GenderValue, RaceOrEthnicityValue } from "../demographics";

export type LocalityLabels = {
Expand Down Expand Up @@ -174,4 +175,5 @@ export type RacialDisparitiesNarrativeContent = {
introduction: string;
introductionMethodology: string;
sections: RacialDisparitiesSections;
supervisionTypes?: SupervisionType[];
};
Original file line number Diff line number Diff line change
Expand Up @@ -288,3 +288,32 @@ describe("available categories", () => {
expect(narrative.allCategories).toMatchSnapshot();
});
});

describe("supervision types", () => {
test("default", async () => {
reactImmediately(() => {
expect(narrative.supervisionTypeList).toEqual([
"supervision",
"parole",
"probation",
]);
expect(narrative.supervisionType).toBe("supervision");
});
});

test("limited", () => {
narrative = RacialDisparitiesNarrative.build({
tenantId: testTenantId,
content: {
...contentFixture.racialDisparitiesNarrative,
supervisionTypes: ["parole"],
},
categoryFilter: contentFixture.demographicCategories.raceOrEthnicity,
});

reactImmediately(() => {
expect(narrative.supervisionTypeList).toEqual(["parole"]);
expect(narrative.supervisionType).toBe("parole");
});
});
});
19 changes: 9 additions & 10 deletions spotlight-client/src/contentModels/RacialDisparitiesNarrative.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,7 @@ type SentencingMetrics = {
probationPctCurrent: number;
};

export const SupervisionTypeList = [
"supervision",
"parole",
"probation",
] as const;
const SupervisionTypeList = ["supervision", "parole", "probation"] as const;
export type SupervisionType = typeof SupervisionTypeList[number];

function getSentencingMetrics(
Expand Down Expand Up @@ -146,7 +142,6 @@ export type TemplateVariables = {
type ConstructorOpts = {
tenantId: TenantId;
defaultCategory?: RaceIdentifier;
defaultSupervisionType?: SupervisionType;
content: RacialDisparitiesNarrativeContent;
categoryFilter?: DemographicCategoryFilter["raceOrEthnicity"];
};
Expand Down Expand Up @@ -193,6 +188,8 @@ export default class RacialDisparitiesNarrative implements Hydratable {

selectedCategory: RaceIdentifier;

readonly supervisionTypeList: SupervisionType[];

supervisionType: SupervisionType;

static build(props: ConstructorOpts): RacialDisparitiesNarrative {
Expand All @@ -202,13 +199,15 @@ export default class RacialDisparitiesNarrative implements Hydratable {
constructor({
tenantId,
defaultCategory,
defaultSupervisionType,
content,
categoryFilter,
}: ConstructorOpts) {
this.tenantId = tenantId;
this.selectedCategory = defaultCategory || "BLACK";
this.supervisionType = defaultSupervisionType || "supervision";
this.supervisionTypeList = [
...(content.supervisionTypes || SupervisionTypeList),
];
[this.supervisionType] = this.supervisionTypeList;
this.chartLabels = content.chartLabels;
this.introduction = content.introduction;
this.introductionMethodology = content.introductionMethodology;
Expand Down Expand Up @@ -763,10 +762,10 @@ export default class RacialDisparitiesNarrative implements Hydratable {
sections.push({
...supervision,
chartData: this.revocationsDataSeries,
supervisionFilter: true,
supervisionFilter: this.supervisionTypeList.length > 1,
download: this.getDownloadFn({
name: "supervision",
fieldsToInclude: ["parole", "probation", "supervision"],
fieldsToInclude: this.supervisionTypeList,
}),
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,7 @@ const content: ExhaustiveTenantContent = {
introduction: `introduction {likelihoodVsWhite.BLACK} {likelihoodVsWhite.HISPANIC}
{likelihoodVsWhite.AMERICAN_INDIAN_ALASKAN_NATIVE}`,
introductionMethodology: "introduction methodology",
supervisionTypes: ["supervision", "parole", "probation"],
sections: {
beforeCorrections: {
title: "beforeCorrections title",
Expand Down

0 comments on commit 218ed17

Please sign in to comment.