Skip to content

Task/update playwright logic#1

Open
JERotter wants to merge 92 commits into
mainfrom
task/update-playwright-logic
Open

Task/update playwright logic#1
JERotter wants to merge 92 commits into
mainfrom
task/update-playwright-logic

Conversation

@JERotter

@JERotter JERotter commented Oct 20, 2025

Copy link
Copy Markdown

This PR includes updates to:

scrape.ts -
const link = page.locator('[href*="/Report/${type}?"]');

was updated to

const docketRow = page.locator('tr:has-text("${docketNum}")');
const link = docketRow.locator('[href*="/Report/${type}?"]').first();
to address a 'Resolved to 2 elements' error.

scrape.ts, type.ts and serialize.ts -
were updated to return the summary and docket URLs. The URLs we need include a dnh value that cannot be derived deterministically from the docket number — it’s generated and owned by the upstream system. To ensure our links remain accurate and resilient to system changes, we fetch the full URLs directly from the API instead of trying to reconstruct them client-side. This makes the automation future-proof and guarantees we always link to the correct court records.

CourtDataExcelScript.ts -
Added an Excel Office Script that invokes the scrAPI lambda and pulls data into the spreadsheets.

CourtDataExcelScript.ts:

🔹 Reads input
Takes docket numbers from the currently active worksheet (column A, rows 2–100)

🔹 Calls backend APIs
For each docket number:
Calls Summary API → returns defendant details + case and charge metadata
Calls Docket API → returns financial balance and payment info

🔹 Extracts and normalizes data
Parses full legal names into First / Middle / Last columns
Handles multiple cases, charges, and sentences per docket
Avoids null/undefined issues with safe fallbacks

🔹 Writes structured output into new worksheets
It creates and populates these tabs:

Sheet Data Stored
Person Info Identifiers, name (parsed), demographics, address, aliases
Cases Case status, judge, arrest/disp dates, charge count
Charges Statutes, grades, dispositions, sentence details
Financial Info Balances, assessments, payments, adjustments
Links JSON data, Clickable URLs to court summary & docket sheets

🔹 Adds interactive URL links
Summary and Docket hyperlinks for the first docket entry
Raw JSON data & links to allow auditors/devs to inspect the unprocessed API response directly

🔹 Performance and reliability features
Includes throttling (150ms delay) to avoid API rate limits
Includes error handling so one failed docket does not stop the entire run
Cleans prior data before writing fresh output

@JERotter JERotter marked this pull request as ready for review October 30, 2025 13:27

@jackmanleydev jackmanleydev left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like a good start. Walked through a potential refactoring options for the excel script and examples of what that could look like. Holding off on going down that path until we get feedback from stakeholders, because most of that code could change if they want the data in a specific format.

Comment thread scripts/CourtDataExcelScript.ts Outdated
Comment thread scripts/CaseReportsData.ts Outdated
Comment thread src/apis/usjs/scrape.ts Outdated
Comment thread src/apis/usjs/scrape.ts Outdated
Comment thread src/apis/usjs/scrape.ts Outdated
Comment thread src/apis/usjs/serialize.ts Outdated
Comment thread src/apis/usjs/serialize.ts Outdated
Comment thread src/README.md Outdated

The script connects to these live endpoints:

- **Summary API**: `https://ocyjm4kh1i.execute-api.us-east-1.amazonaws.com/prod/usjs/v1/summary`

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hardcoding isn't...great overall.
Let's at least put a DNS name on top of this longer term. Will go through that process with PE.

Comment thread src/README.md Outdated
Comment thread src/README.md Outdated
Comment thread src/README.md
JERotter and others added 30 commits March 5, 2026 12:59
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants