Skip to content

Commit

Permalink
Merge pull request #118 from openstates/realtime-skip-bills-postimpor…
Browse files Browse the repository at this point in the history
…t/OS-1432

Allow postimport hook to be skipped in os-update command
  • Loading branch information
NewAgeAirbender authored Oct 26, 2023
2 parents f513ebc + 09db4e4 commit 77dc237
Show file tree
Hide file tree
Showing 10 changed files with 16 additions and 29 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
*swp
.cache
.coverage
.python-version
.tox
.venv/
__pycache__
Expand Down
4 changes: 0 additions & 4 deletions .idea/misc.xml

This file was deleted.

15 changes: 0 additions & 15 deletions .idea/openstates-core.iml

This file was deleted.

1 change: 1 addition & 0 deletions .python-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
3.9.15
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

## 6.17.9 - October 26, 2023

* allow postimport hook to be skipped in os-update command

## 6.17.8 - October 16, 2023

* set application_name for better performance monitoring
Expand Down
7 changes: 4 additions & 3 deletions openstates/importers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,9 @@ class BaseImporter:
merge_related: typing.Dict[str, typing.List[str]] = {}
cached_transformers: _TransformerMapping = {}

def __init__(self, jurisdiction_id: str) -> None:
def __init__(self, jurisdiction_id: str, do_postimport=True) -> None:
self.jurisdiction_id = jurisdiction_id
self.do_postimport = do_postimport
self.json_to_db_id: typing.Dict[str, _ID] = {}
self.duplicates: typing.Dict[str, str] = {}
self.pseudo_id_cache: typing.Dict[str, typing.Optional[_ID]] = {}
Expand Down Expand Up @@ -305,8 +306,8 @@ def import_data(
record[what] += 1

# all objects are loaded, a perfect time to do inter-object resolution and other tasks
if self.json_to_db_id:
# only do postimport step if there are some items of this type
if self.json_to_db_id and self.do_postimport:
# only do postimport step if requested by client code AND there are some items of this type
# resolution of bills take a long time if not
# and events & votes get deleted!
self.postimport()
Expand Down
4 changes: 2 additions & 2 deletions openstates/importers/bills.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,8 @@ class BillImporter(BaseImporter):
}
preserve_order = {"actions"}

def __init__(self, jurisdiction_id: str):
super(BillImporter, self).__init__(jurisdiction_id)
def __init__(self, jurisdiction_id: str, do_postimport=True):
super(BillImporter, self).__init__(jurisdiction_id, do_postimport)
self.org_importer = OrganizationImporter(jurisdiction_id)

def get_object(self, bill: _JsonDict) -> Model:
Expand Down
3 changes: 2 additions & 1 deletion openstates/importers/events.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,9 @@ def __init__(
self,
jurisdiction_id: str,
vote_event_importer: VoteEventImporter,
do_postimport=True,
):
super(EventImporter, self).__init__(jurisdiction_id)
super(EventImporter, self).__init__(jurisdiction_id, do_postimport)
self.org_importer = OrganizationImporter(jurisdiction_id)
self.vote_event_importer = vote_event_importer

Expand Down
4 changes: 2 additions & 2 deletions openstates/importers/vote_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,8 @@ class VoteEventImporter(BaseImporter):
"sources": (VoteSource, "vote_event_id", {}),
}

def __init__(self, jurisdiction_id: str, bill_importer: BillImporter):
super(VoteEventImporter, self).__init__(jurisdiction_id)
def __init__(self, jurisdiction_id: str, bill_importer: BillImporter, do_postimport=True):
super(VoteEventImporter, self).__init__(jurisdiction_id, do_postimport)
self.org_importer = OrganizationImporter(jurisdiction_id)
self.bill_importer = bill_importer
self.seen_bill_ids: typing.Set[str] = set()
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "openstates"
version = "6.17.8"
version = "6.17.9"
description = "core infrastructure for the openstates project"
authors = ["James Turk <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit 77dc237

Please sign in to comment.