-
-
Notifications
You must be signed in to change notification settings - Fork 182
feat(recap): Enhances appellate docket purchase to support ACMS cases #5960
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
feat(recap): Enhances appellate docket purchase to support ACMS cases #5960
Conversation
Introduces `should_check_acms_court` to determine whether a given `court_id` requires ACMS-specific handling (currently limited to "ca2" and "ca9").
Extends `purchase_appellate_docket_by_docket_number` to support courts that use the new Appellate Case Management System (ACMS), specifically CA2 and CA9. When a requested docket belongs to an ACMS-enabled court, the helper performs a preliminary case search to determine whether the case is hosted in ACMS or standard PACER. If an ACMS case is detected, the function uses `ACMSDocketReport` to retrieve docket data; otherwise, it falls back to the existing `AppellateDocketReport` logic.
Refines the `merge_pacer_docket_into_cl_docket` method to save raw docket data as HTML or JSON based on report type.
Introduces `FakeNewAppellateCaseDocketReport`, `FakeEmptyAcmsCaseSearch`, and `FakeAcmsCaseSearch` to simulate various PACER and ACMS scenarios in tests.
Enhances existing tests for appellate docket fetching by mocking ACMS helpers.
Introduces two test cases to verify ACMS docket handling: - `test_can_fetch_acms_docket_by_docket_number` checks ACMS integration when fetching by docket number. - `test_can_fetch_acms_docket_by_docket_id` verifies behavior when fetching by existing docket ID.
Not much code to add something so big. Nice to see, thanks. |
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.
Thanks @ERosendo just a couple of comments.
tested the docket fetch and it’s working. However, I’m curious where get_acms_tokens
is being set to True to trigger ACMS authentication.
I couldn’t find it in the code.
cl/recap/tasks.py
Outdated
docket_data["docket_entries"] = sorted( | ||
docket_data["docket_entries"], | ||
key=lambda d: ( | ||
d["date_filed"], | ||
d["document_number"] is None, | ||
d["document_number"], | ||
), | ||
) |
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.
I remember we have this sorting logic in a different method. Can we create a method with this logic that can be reused?
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.
You're correct. I'll add the new helper method and refactor this code
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.
btw when testing the fetch attachment page PR I found this docket:
https://www.courtlistener.com/docket/68490335/united-states-of-america-v-raji/
Which I retrieved using the fetch API in my local env.
As you can see the entry 17 is in the wrong place due to date Field is being prioritized over the document number.

I checked in PACER and the date filed is correct.
Would it be possible to prioritize the document number, and use the date filed if it's None?
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.
Since we just introduced a method to sort ACM entries, I think we could check whether all docket entries in the input have a document_number. If they do, we can sort purely by that number. Otherwise, we fall back to the existing sort function. What do you think?
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.
Yes, I think this makes sense. We can leverage the fact that all entries are available when fetching the docket.
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.
cool! i'll refine the new helper method
Updates the `sort_acms_docket_entries` helper to check if all entries have a `document_number` and, if so, sort solely by that field.
@albertisfu Thanks for the review. I’ve addressed all your comments and also added a final refinement to the logic for sorting ACMS entries.
Currently, the token is generated only when a user attempts to fetch an ACMS document. I’m planning to open a follow-up PR to store the ACMS credentials in cache so we can reuse them and avoid recomputing the token.. |
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.
Thanks @ERosendo this looks ready to be merged!
Key changes:
Introduces a new helper function that centralizes logic to determine whether a given
court_id
requires ACMS-specific handlingUpdates
purchase_appellate_docket_by_docket_number
to detect ACMS cases and switch toACMSDocketReport
when appropriate. Falls back toAppellateDocketReport
for standard PACER courts.Tweaks
merge_pacer_docket_into_cl_docket
to save raw ACMS data as.json
instead of.html
(ACMS does not return a traditional HTML response)Adds
FakeAcmsCaseSearch
,FakeAcmsDocketReport
, and related fakes for isolated ACMS test behavior.Depends on #5938 and freelawproject/juriscraper#1494
Fixes #5154