Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Previously, we went by the jurisction of the containing CIPRS record … #471

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
6 changes: 2 additions & 4 deletions dear_petition/petition/types/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,9 @@ 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"
)
qs = offense_records.values("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
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,11 @@ def test_distinct_petition__many(batch):
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)
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
Loading