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 Mar 23, 2024
1 parent 3814c36 commit 870427e
Show file tree
Hide file tree
Showing 6 changed files with 7 additions and 6 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 @@ -7,7 +7,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 @@ -7,7 +7,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 @@ -54,6 +54,7 @@ def test_offense_records_by_jurisdiction(batch, jurisdiction):
offense = OffenseFactory(
disposition_method=constants.DISMISSED_DISPOSITION_METHODS[0],
ciprs_record=ciprs_record,
jurisdiction=jurisdiction,
)
offense_record = OffenseRecordFactory(action="CHARGED", offense=offense)
records = batch.dismissed_offense_records(jurisdiction=jurisdiction)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ def test_distinct_petition__many(batch):
record = CIPRSRecordFactory(
jurisdiction=jurisdiction, county=county, batch=batch
)
offense = OffenseFactory(disposition_method=method, ciprs_record=record)
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 @@ -25,7 +25,7 @@ def get_offense_records(batch, jurisdiction=""):
return qs # 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 870427e

Please sign in to comment.