-
-
Notifications
You must be signed in to change notification settings - Fork 182
feat(recap): Adds support for ACMS attachment page purchases #5971
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
Merged
albertisfu
merged 8 commits into
main
from
4938-feat-adds-support-to-purchase-acms-attachment-pages
Jul 17, 2025
+174
−39
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
57c6a56
feat(recap): Removes early return for ACMS attachment pages
ERosendo d5b197f
feat(corpus_importer): Adds support for fetching ACMS att pages
ERosendo f92e20b
feat(recap): Adds support for parsing and merging ACMS att pages
ERosendo 8f2912a
test(recap): Adds test for fetching attachment pages from ACMS
ERosendo 924eccc
fix(tests): Restores accidentally removed test
ERosendo 0322c73
feat(acms): Adds check for missing case IDs in ACMS cases
ERosendo 3a7eef8
feat(mergers): Dynamically set attachment filename based on ACMS flag
ERosendo 9e94ffd
Merge branch 'main' into 4938-feat-adds-support-to-purchase-acms-atta…
albertisfu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import asyncio | ||
import concurrent.futures | ||
import hashlib | ||
import json | ||
import logging | ||
from dataclasses import dataclass | ||
from datetime import datetime | ||
|
@@ -2119,9 +2120,10 @@ def fetch_attachment_page(self: Task, fq_pk: int) -> list[int]: | |
self.request.chain = None | ||
return [] | ||
|
||
if rd.is_acms_document(): | ||
msg = "ACMS attachment pages are not currently supported" | ||
mark_fq_status(fq, msg, PROCESSING_STATUS.FAILED) | ||
is_acms_case = rd.is_acms_document() | ||
if is_acms_case and not pacer_case_id: | ||
msg = f"Unable to complete purchase: Missing case_id for RECAP Document object {rd.pk}." | ||
mark_fq_status(fq, msg, PROCESSING_STATUS.NEEDS_INFO) | ||
self.request.chain = None | ||
return [] | ||
|
||
|
@@ -2179,32 +2181,44 @@ def fetch_attachment_page(self: Task, fq_pk: int) -> list[int]: | |
) | ||
raise self.retry(exc=exc) | ||
|
||
text = r.response.text | ||
is_appellate = is_appellate_court(court_id) | ||
# Determine the appropriate parser function based on court jurisdiction | ||
# (appellate or district) | ||
att_data_parser = ( | ||
get_data_from_appellate_att_report | ||
if is_appellate | ||
else get_data_from_att_report | ||
) | ||
att_data = att_data_parser(text, court_id) | ||
if not is_acms_case: | ||
text = r.response.text | ||
# Determine the appropriate parser function based on court jurisdiction | ||
# (appellate or district) | ||
att_data_parser = ( | ||
get_data_from_appellate_att_report | ||
if is_appellate | ||
else get_data_from_att_report | ||
) | ||
att_data = att_data_parser(text, court_id) | ||
else: | ||
att_data = r.data | ||
text = json.dumps(r.data, default=str) | ||
|
||
if att_data == {}: | ||
msg = "Not a valid attachment page upload" | ||
mark_fq_status(fq, msg, PROCESSING_STATUS.INVALID_CONTENT) | ||
self.request.chain = None | ||
return [] | ||
|
||
if is_acms_case: | ||
document_number = att_data["entry_number"] | ||
elif is_appellate: | ||
# Appellate attachments don't contain a document_number | ||
document_number = None | ||
else: | ||
document_number = att_data["document_number"] | ||
|
||
try: | ||
async_to_sync(merge_attachment_page_data)( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Would it be a good idea to update the |
||
rd.docket_entry.docket.court, | ||
pacer_case_id, | ||
att_data["pacer_doc_id"], | ||
# Appellate attachments don't contain a document_number | ||
None if is_appellate else att_data["document_number"], | ||
document_number, | ||
text, | ||
att_data["attachments"], | ||
is_acms_attachment=is_acms_case, | ||
) | ||
except RECAPDocument.MultipleObjectsReturned: | ||
msg = ( | ||
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When we start ingesting ACMS email notifications that don't include a
pacer_case_id
, we'll retrieve it using theAcmsCaseSearch
API. However, thepacer_doc_id
will be empty for documents merged from ACMS email notifications.So, I think it would be a good idea to check these values before querying the report as a safeguard. If either is missing, we could raise an error and store it in the FQ, so users understand why the fetch can't complete.
It might be better to perform this check in
fetch_attachment_page
, since that’s where these values are initially retrieved.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great idea — thanks! I'll update the code.