Skip to content

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

Merged
merged 13 commits into from
Jul 17, 2025

Conversation

ERosendo
Copy link
Contributor

@ERosendo ERosendo commented Jul 13, 2025

Key changes:

  • Introduces a new helper function that centralizes logic to determine whether a given court_id requires ACMS-specific handling

  • Updates purchase_appellate_docket_by_docket_number to detect ACMS cases and switch to ACMSDocketReport when appropriate. Falls back to AppellateDocketReport 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

ERosendo added 8 commits July 13, 2025 17:59
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.
@ERosendo ERosendo marked this pull request as ready for review July 14, 2025 13:14
@ERosendo ERosendo linked an issue Jul 14, 2025 that may be closed by this pull request
@ERosendo ERosendo requested a review from mlissner July 14, 2025 13:18
@ERosendo ERosendo moved this to To Do in Sprint (Web Team) Jul 14, 2025
@mlissner
Copy link
Member

Not much code to add something so big. Nice to see, thanks.

@mlissner mlissner requested review from albertisfu and removed request for mlissner July 14, 2025 13:24
@mlissner mlissner assigned albertisfu and unassigned mlissner Jul 14, 2025
Base automatically changed from 5921-fix-login-exception-for-acms to main July 15, 2025 16:32
@albertisfu albertisfu moved this from To Do to In progress in Sprint (Web Team) Jul 15, 2025
Copy link
Contributor

@albertisfu albertisfu left a 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.

Comment on lines 2450 to 2457
docket_data["docket_entries"] = sorted(
docket_data["docket_entries"],
key=lambda d: (
d["date_filed"],
d["document_number"] is None,
d["document_number"],
),
)
Copy link
Contributor

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?

Copy link
Contributor Author

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

Copy link
Contributor

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.

Screenshot 2025-07-16 at 2 45 32 p m

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?

Copy link
Contributor Author

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?

Copy link
Contributor

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.

Copy link
Contributor Author

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

@albertisfu albertisfu moved this from In progress to To Do in Sprint (Web Team) Jul 16, 2025
@albertisfu albertisfu assigned ERosendo and unassigned albertisfu Jul 16, 2025
@ERosendo
Copy link
Contributor Author

@albertisfu Thanks for the review. I’ve addressed all your comments and also added a final refinement to the logic for sorting ACMS entries.

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.

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..

@ERosendo ERosendo assigned albertisfu and unassigned ERosendo Jul 17, 2025
@ERosendo ERosendo requested a review from albertisfu July 17, 2025 00:39
@albertisfu albertisfu moved this from To Do to In progress in Sprint (Web Team) Jul 17, 2025
Copy link
Contributor

@albertisfu albertisfu left a 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!

@albertisfu albertisfu merged commit cc21b42 into main Jul 17, 2025
9 checks passed
@albertisfu albertisfu deleted the 5154-feat-add-support-to-purchase-acms-dockets branch July 17, 2025 19:28
@github-project-automation github-project-automation bot moved this from In progress to Done in Sprint (Web Team) Jul 17, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Review: Implementing logic to purchase ACMS dockets
3 participants