Skip to content

Commit

Permalink
District court offenses were showing up on the superior court petitio…
Browse files Browse the repository at this point in the history
…ns because the filter condition was using the jurisdiction fo the CIPRS record rather than the jurisdiction of the record. I suspect this is an artifact of the time when we thought a CIPRS record had only one jurisdiction. We now know that it is possible for a CIPRS record to have both in the case of superseding indictments. The convictions petitions should go by the jurisdiction of the offense, rather than the CIPRS record
  • Loading branch information
georgehelman committed Jan 11, 2025
1 parent 7b5d576 commit 584031c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dear_petition/petition/types/dismissed.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
def get_offense_records(batch, jurisdiction=""):
qs = OffenseRecord.objects.filter(offense__ciprs_record__batch=batch)
if jurisdiction:
qs = qs.filter(offense__ciprs_record__jurisdiction=jurisdiction)
qs = qs.filter(offense__jurisdiction=jurisdiction)
qs = qs.filter(build_query()).exclude(severity="INFRACTION")
return qs.select_related("offense__ciprs_record__batch")

Expand Down
4 changes: 2 additions & 2 deletions dear_petition/petition/types/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ def petition_offense_records(batch, petition_type, jurisdiction=""):

def identify_distinct_petitions(offense_records):
qs = offense_records.values(
"offense__ciprs_record__jurisdiction", "offense__ciprs_record__county"
"offense__jurisdiction", "offense__ciprs_record__county"
)
qs = qs.values(
jurisdiction=F("offense__ciprs_record__jurisdiction"),
jurisdiction=F("offense__jurisdiction"),
county=F("offense__ciprs_record__county"),
).distinct()
logger.info(f"Distinct petitions: {list(qs.values_list('county', 'jurisdiction'))}")
Expand Down
2 changes: 1 addition & 1 deletion dear_petition/petition/types/not_guilty.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
def get_offense_records(batch, jurisdiction=""):
qs = OffenseRecord.objects.filter(offense__ciprs_record__batch=batch)
if jurisdiction:
qs = qs.filter(offense__ciprs_record__jurisdiction=jurisdiction)
qs = qs.filter(offense__jurisdiction=jurisdiction)
query = build_query()
qs = qs.filter(query).exclude(severity="INFRACTION")
return qs.select_related("offense__ciprs_record__batch")
Expand Down
1 change: 1 addition & 0 deletions dear_petition/petition/types/tests/test_dismissed.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ def test_offense_records_by_jurisdiction(batch, jurisdiction):
offense = OffenseFactory(
disposition_method=constants.CIPRS_DISPOSITION_METHODS_DISMISSED[0],
ciprs_record=ciprs_record,
jurisdiction=jurisdiction,
)
offense_record = OffenseRecordFactory(action="CHARGED", offense=offense)
records = batch.dismissed_offense_records(jurisdiction=jurisdiction)
Expand Down
6 changes: 4 additions & 2 deletions dear_petition/petition/types/tests/test_distinct_petitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,10 @@ def test_distinct_petition__many(batch):
method = constants.CIPRS_DISPOSITION_METHODS_DISMISSED[0]
for jurisdiction in [constants.DISTRICT_COURT, constants.SUPERIOR_COURT]:
for county in ["DURHAM", "WAKE"]:
record = CIPRSRecordFactory(jurisdiction=jurisdiction, county=county, batch=batch)
offense = OffenseFactory(disposition_method=method, ciprs_record=record)
record = CIPRSRecordFactory(
jurisdiction=jurisdiction, county=county, batch=batch
)
offense = OffenseFactory(disposition_method=method, ciprs_record=record, jurisdiction=jurisdiction,)
OffenseRecordFactory(action="CHARGED", offense=offense)
petition_types = identify_distinct_petitions(batch.dismissed_offense_records())
assert petition_types.count() == 4
Expand Down
2 changes: 1 addition & 1 deletion dear_petition/petition/types/underaged_convictions.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ def get_offense_records(batch, jurisdiction=""):
) # We can't determine this petition type without the date of birth

if jurisdiction:
qs = qs.filter(offense__ciprs_record__jurisdiction=jurisdiction)
qs = qs.filter(offense__jurisdiction=jurisdiction)

query = build_query(dob)
qs = qs.filter(query).exclude(severity="INFRACTION")
Expand Down

0 comments on commit 584031c

Please sign in to comment.