diff --git a/scl.py b/scl.py index 44f26e3..58b8fd5 100644 --- a/scl.py +++ b/scl.py @@ -90,9 +90,10 @@ class SclOutage(Base): status: Mapped[Optional[str]] = mapped_column() no_longer_in_response_time: Mapped[Optional[datetime]] = mapped_column() start_time: Mapped[datetime] = mapped_column() + num_people: Mapped[int] = mapped_column() def __repr__(self) -> str: - return f"SclOutage(scl_outage_id={self.scl_outage_id!r}, most_recent_post_id={self.most_recent_post_id!r}, last_updated_time={self.last_updated_time!r}, no_longer_in_response_time={self.no_longer_in_response_time!r}), start_time={self.start_time!r})" + return f"SclOutage(scl_outage_id={self.scl_outage_id!r}, most_recent_post_id={self.most_recent_post_id!r}, last_updated_time={self.last_updated_time!r}, no_longer_in_response_time={self.no_longer_in_response_time!r}), start_time={self.start_time!r}), num_people={self.num_people!r})" engine = create_engine("sqlite:///scl.db") @@ -152,6 +153,8 @@ with Session(engine) as session: existing_record.status = status updated_properties.append("status") updated_entries.append("Status: {}".format(status)) + if existing_record.num_people != event["numPeople"]: + existing_record.num_people = event["numPeople"] if updated_properties: updated_properties.sort() @@ -366,6 +369,7 @@ with Session(engine) as session: status=status, outage_size=outage_size, start_time=start_time, + num_people=event["numPeople"] ) session.add(new_outage_record) session.commit()