Skip to content
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

USA/NV: fix small bugs affecting bill import #5083

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions scrapers/nv/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,7 @@ def process_page(self):
date_re = re.compile(r"Date\s+(?P<date>.*)", re.U | re.I)
index = 0

date_motion_counts = {}
for row in CSS(".vote-revision", min_items=0).match(self.root):
summary = summaries[index]
index += 1
Expand All @@ -472,6 +473,16 @@ def process_page(self):
start_date = date_match.groupdict()["date"]
start_date = parse_date(start_date)

# sometimes two votes with the same motion happen on the same day
# hence we need to make motion text unique otherwise import fails
date_motion = f"{start_date.date()}{summary}"
if start_date is not None and date_motion in date_motion_counts:
num_existing = date_motion_counts[date_motion]
summary = f"{summary} ({num_existing + 1})"
date_motion_counts[date_motion] += 1
else:
date_motion_counts[date_motion] = 1

vote = VoteEvent(
chamber=chamber,
motion_text=summary,
Expand Down
2 changes: 1 addition & 1 deletion scrapers/usa/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -411,7 +411,7 @@ def scrape_amendments(self, bill, xml, session, chamber, bill_id):
self.warning("Check amendment url ordinals")

bill.add_document_link(
note=f"{self.get_xpath(row, 'type')} {num}",
note=f"{self.get_xpath(row, 'type')} {num}"[:300],
url=f"https://www.congress.gov/amendment/{session}th-congress/{slugs[self.get_xpath(row, 'type')]}/{num}",
media_type="text/html",
)
Expand Down
Loading