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

Use incoming Chamber in resolve_person() to improve sponsorship matches #139

Merged
merged 2 commits into from
Sep 10, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
6 changes: 6 additions & 0 deletions openstates/importers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -536,6 +536,12 @@ def resolve_person(

# turn spec into DB query
spec = get_pseudo_id(psuedo_person_id)

# if chamber is included in pseudo_person_id, use that as org_classification
if "chamber" in spec and org_classification is None:
org_classification = spec["chamber"]
del spec["chamber"]

if list(spec.keys()) == ["name"]:
# if we're just resolving on name, include other names and family name
name = spec["name"]
Expand Down
7 changes: 5 additions & 2 deletions openstates/scrape/bill.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ def add_sponsorship(
entity_type,
primary,
*,
chamber=None,
chamber=None, # upper, lower or legislature
entity_id=None,
):
sp = {
Expand All @@ -124,7 +124,10 @@ def add_sponsorship(
# overwrite the id that exists
if entity_type:
if not entity_id:
entity_id = _make_pseudo_id(name=name)
if chamber is not None:
entity_id = _make_pseudo_id(name=name, chamber=chamber)
else:
entity_id = _make_pseudo_id(name=name)
sp[entity_type + "_id"] = entity_id
if sp in self.sponsorships:
warnings.warn(f"duplicate sponsor {sp}", RuntimeWarning)
Expand Down
Loading