Repository navigation
Show who introduced a 2027 bill and its session in the bill overview - #1646
Conversation
The tracker's 2027 import records each bill's sponsors, introduced date, session and a link to its text (state-legislative-tracker #241 defines the fields). The bill feed reads them from research rows when present, and the overview adds "Introduced January 12, 2027 by Jane Doe (R-7) and 3 others · 2027-2028 Regular Session" and prefers the import's bill text link. Older analyses read exactly as before: no sponsor is ever taken from the tracker's author field. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
PavelMakarchuk
left a comment
There was a problem hiding this comment.
Review at dba4aaa
This PR reads six optional 2027 fields from the tracker's research rows into TrackedBill: sponsors, introduced date, session, bill text link, saved report link and approval time. The bill overview then shows one line, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027-2028 Regular Session". The "Bill text" link now prefers the import's bill_text_url. Rows without the new fields map to the same TrackedBill as before, and the author field is still never read as a sponsor.
Verdict: REQUEST_CHANGES
The code is clean and older analyses do not change. One item is about the data contract: the session name that the tracker will write is not the label that this PR expects.
SHOULD ADDRESS
1. The session label will show the OpenStates identifier, for example "2027_28 session".
app/src/api/billFeed.ts:812 reads research.session_name, and app/src/libs/flagship/billOverview.ts:34-36 prints it, with " session" added when the word is not there. The tests use "2027-2028 Regular Session" (billFeedMocks.ts:237, trackedBillMocks.ts:74). But the tracker stores a different value:
- Tracker PR 241 (
scripts/sql/010_add_app_v3_bill_fields.sql) definesresearch.session_nameas "the bill's session label, as in processed_bills". - In
processed_bills,session_nameis the OpenStates session identifier. The importer test in tracker PR 243 assertsbill["session_name"] == "2027_28". The human name ("2027-2028 Regular Session") is only in the/jurisdictionsdata, and the importer does not store it.
When I call introducedLine with importer-shaped data, I get:
{ name: '2027_28', year: 2027 }gives "Introduced January 12, 2027 · 2027_28 session".{ name: '20272028', year: 2027 }gives "20272028 session".
Thus every 2027 bill report will show an identifier, not a session name. Fix it on one side, and make the test fixtures agree with the tracker:
- In the tracker, store the session's display name (for example a new
session_label, orsession_nameset from the session'sname). Then this PR reads that field. - Or, in this PR, do not print
session.namewhen it looks like an identifier. Build the label fromsession_yearinstead (for example "2027 session"), until the tracker stores a display name.
Also change INTAKE_ROWS to use a real importer value ('2027_28'), so that the test shows what readers will see.
SUGGESTION
2. A sponsor without a party shows only a number. billOverview.ts:12. A sponsor with a district and no party gives "Jane Doe (7)". The PR's own test expects "B (3)". A bare number in parentheses does not tell a reader that it is a district. The tracker sets party to null for committee sponsors and for people without a linked record. Show the tag only when there is a party, or write "District 7".
3. A committee can be the named sponsor. The tracker keeps committee sponsors (entity_type: "organization", for example "Ways and Means"). When a committee is the primary sponsor, the line reads "Introduced by Ways and Means and 1 other". That is correct for committee bills, but the feed drops entity_type, so a later change cannot tell a committee from a person. Keep entity_type on BillSponsor, or add a test that states the intended text for a committee bill.
4. One date helper, two copies. longDate in billOverview.ts:3 is the same as formatDate in BillReport.page.tsx:44. Export one helper and use it in both places. Both copies parse the date as local midnight from the first 10 characters, so the date does not move in any time zone. I checked a timestamp input in two far-apart time zones, and both give "January 12, 2027".
5. appReportUrl and approvedAt have no reader yet. That is acceptable as groundwork for the Tracked bills work. The contract also defines app_report_id and review_pr_url, which this PR does not read. A short note in the description would help the next change.
What I checked
- The fields against tracker PR 241 (
docs/APP_V3_BILL_CONTRACT.md, migration010). The namessponsors,introduced_date,bill_text_url,session_name,session_year,app_report_urlandapproved_atagree.session_yearisINTEGERand the feed requires an integer, which agrees.introduced_dateisDATE, so the feed gets "YYYY-MM-DD". The text link falls back toresearch.url, as the contract says. - The sponsor shape against tracker PR 243 (
bill_sponsorsinopenstates_monitor.py, migration009):name,primary,partyanddistrictagree. The importer sorts primary sponsors first, and the feed sorts them again. Blank names are dropped. - Older rows:
intakeFieldsreturns an empty object for a row without the fields, and the test checks thatsponsors,sessionandbillTextUrlare absent. - Design: the new line uses the existing
Caption(typography.fontSize.xs,colors.text.secondary). There are no new colors or sizes. The text is in sentence case. The line is plain text, so it adds no new controls for keyboard or screen reader users. - A probe of
introducedLinewith importer-shaped data: session identifiers, committee sponsors, no party, Nebraska "Nonpartisan" ("N-7"), Massachusetts district names ("D-1st Hampden"), three primary sponsors, a timestamp date and an invalid date. - Local runs (Node 22.23.1, bun 1.3.9):
- Targeted vitest (
billFeed,billOverview,BillReport): 79 passed in 3 files. - App
bun run test: 8,130 passed and 10 skipped in 612 files. - App typecheck, eslint (no warnings allowed) and prettier: pass.
calculator-app(which serves/[countryId]/report/bill/[billId]): typecheck andnext buildpass.
- Targeted vitest (
- CI at this head: lint, typecheck, tests, build and visual regression pass.
Pavel's review of #1646: - The tracker stores the OpenStates session identifier ("2027_28") in research.session_name, so the overview showed "2027_28 session". It now shows a session name only when it has a space ("2027-2028 Regular Session") and otherwise reads "2027 session" from session_year. The fixtures use the importer's real value. - A sponsor without a party gets no tag; "Jane Doe (7)" read as nothing. - The feed keeps OpenStates' entity_type on each sponsor, so a committee sponsor can be told from a person; a test states the committee line. - BillReport and the overview share one date helper, formatLongDate. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
After #1646's review fix, the overview reads "2027 session" from the year; the fixtures now carry OpenStates' real value ("2027_28"). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Thanks, Pavel. Fixed in 98a993f. Should address
Suggestions
Checks at 98a993f:
#1658, which is stacked on this branch, now includes these changes; its fixtures use |
PavelMakarchuk
left a comment
There was a problem hiding this comment.
Review at 98a993f
This PR reads six optional 2027 fields from the tracker's research rows into TrackedBill: sponsors, introduced date, session, bill text link, saved report link and approval time. The bill overview shows one line, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027 session". The new commit changes how the line shows the session and sponsors, keeps OpenStates' entity_type on each sponsor, and shares one date helper with the report page.
Verdict: APPROVE
All five earlier items are fixed. I found two small new display cases, both suggestions.
Earlier items
- Session label shows the OpenStates identifier (SHOULD ADDRESS): fixed.
sessionText(app/src/libs/flagship/billOverview.ts:33-42) showssession.nameonly when it has a space. Otherwise it reads "2027 session" fromsession_year. The fixtures now use the importer's2027_28, and a table test covers the identifier forms. Tracker #241 (docs/APP_V3_BILL_CONTRACT.md, at ea9c1e6) now says thatsession_nameis the identifier and that App v3 reads the year. My probe results:2027_28,20272028,2027-2028(no space),2027and2027S1, each with year 2027: "2027 session".2027-2028with no year,2025_26with no year, a missing session,{}, and year0: no session text. The line does not show "undefined" or an empty " · ".- "2027-2028 Regular Session": shown as written. "2027 First Special": "2027 First Special session".
- Texas called session
891and Massachusetts194th, each with year 2025: "2025 session".
- A sponsor without a party shows only a number (SUGGESTION): fixed.
sponsorLabel(billOverview.ts:19-25) adds a tag only when there is a party. "Jane Doe" with district 7 and no party reads "Jane Doe". A party with no district reads "Jane Doe (R)". Nebraska "Nonpartisan" still reads "(N-7)". - A committee can be the named sponsor (SUGGESTION): fixed.
BillSponsor.entityTypekeepspersonororganization(app/src/api/billFeed.ts:107-108, 812-814). Other values, such as the importer's"", are dropped. A committee never gets a tag, even when a row gives it a party. A test states the committee line, and the feed fixture has a committee sponsor. - One date helper, two copies (SUGGESTION): fixed.
formatLongDateis exported frombillOverview.ts, andBillReport.page.tsxuses it for "Analyzed" and "computed". It has tests for a date, a timestamp with an offset and an invalid value. appReportUrlandapprovedAthave no reader yet (SUGGESTION): fixed. The description now says that Tracked bills (#1658) orders byapprovedAt, and it notesapp_report_idandreview_pr_urlfor the next change.
SUGGESTION
6. A special session reads the same as the regular session. billOverview.ts:38-40. OpenStates special-session identifiers have no space, for example 2027S1. With year 2027, the line reads "2027 session", the same as a bill from the 2027 regular session. A reader cannot see that the bill is from a special session. A possible fix: when the identifier has a letter after the year (such as S1), write "2027 special session". Or accept this until the tracker stores a display name, and add the 2027S1 row to the test name so the choice is clear.
7. A federal session reads "120th Congress session". billOverview.ts:35-37. The feed includes federal bills, and the tracker's Congress monitor stores session_name as "119th Congress" (scripts/congress_monitor.py:250). That name has a space and no word "session", so the line adds " session". This behavior was also in the earlier head, and it shows only if /encode-bill copies the federal session_name into research. A possible fix: do not add " session" when the name ends in "Congress". Add a test row for it.
What I checked
- Each earlier item, with the unit tests and a probe of
introducedLineandformatLongDate. The probe used the session forms above, committee sponsors with and withoutentityType, a committee with a party, a party with no district, and Nebraska "Nonpartisan". formatLongDatein three time zones (UTC-5, UTC+14 and UTC-11): "2027-01-12", "2027-01-12T23:30:00-08:00" and "2027-01-12T02:00:00Z" all give "January 12, 2027". "soon" and "" are returned as they are.- The fields against tracker PR 241 at ea9c1e6 (contract and migration
010) and PR 243 at e0cd58b (bill_sponsorsinopenstates_monitor.py). The importer writesentity_typeas OpenStates gives it, or"".session_yearis the first calendar year of the session, which agrees with "2027 session" for2027_28. - The diff from dba4aaa to 98a993f: 8 files, 112 lines added and 34 removed. The local
formatDateinBillReport.page.tsxis removed, and no other file used it. - Local runs (bun 1.3.9):
- Targeted vitest (
billFeed,billOverview,BillReport): 91 passed in 3 files. - App
bun run test: 8,142 passed and 10 skipped in 612 files. - App typecheck, eslint and stylelint (no warnings allowed) and prettier: pass.
calculator-app(which serves the bill report page): typecheck andnext buildpass.
- Targeted vitest (
- CI at this head: all 12 checks pass.
From the 2027 sessions on, state bills are scored and published through App v3 (Teamverse p301; Tracked bills is milestone p453). This PR is the data groundwork for the bill overview. The Tracked bills section, session filter and state map are left to the p453 work.
What changes
Bill feed.
TrackedBillgains six optional fields from the tracker'sresearchrows:sponsors, primary first, with party, district and OpenStates' entity type (organizationfor a committee);introducedDate;session, the OpenStates session identifier (for example2027_28) and the session's start year;billTextUrl;appReportUrl, the saved App v3 report the review approved;approvedAt.Nothing reads
appReportUrlyet;approvedAtorders bills in the Tracked bills section (Tracked bills section in App v3: session map and list, example households on bill reports #1658). The contract also definesapp_report_idandreview_pr_url, which this PR doesn't read: the report page can use the first to open the saved report in place, and the second to link the review.The tracker defines these fields in its App v3 bill contract (state-legislative-tracker #241). The feed already reads
researchwithselect=*, so no query changes: a field appears once the tracker writes it.Overview.
BillOverviewLeadadds one line when the fields exist, for example "Introduced January 12, 2027 by Primary Name (R-7) and 1 other · 2027 session". It uses the import's bill text link beforesourceUrl. The line comes fromlibs/flagship/billOverview.ts.formatLongDate.Older analyses don't change. A row without the fields maps to the same
TrackedBillas before. A sponsor is never taken from the tracker'sauthorfield, which is a post's author as often as a sponsor; the existing "no Sponsored by" test still holds.Checks
bun run checkinapp/(typecheck, eslint with no warnings allowed, prettier): passes.app/vitest suite: 8,142 passed, 10 skipped, 0 failed (after Pavel's review, at 98a993f).Order
Nothing breaks if this merges before the tracker writes the fields: they are optional and read from
select=*. Tracker migration010adds them toresearch, and/encode-billfills them when it moves to scoring through the Public API (p451).🤖 Generated with Claude Code