Log the number of people

This commit is contained in:
Liam Steckler 2024-01-29 22:50:37 -05:00
parent ea5d52494e
commit 57ccf817e2

6
scl.py
View file

@ -90,9 +90,10 @@ class SclOutage(Base):
status: Mapped[Optional[str]] = mapped_column() status: Mapped[Optional[str]] = mapped_column()
no_longer_in_response_time: Mapped[Optional[datetime]] = mapped_column() no_longer_in_response_time: Mapped[Optional[datetime]] = mapped_column()
start_time: Mapped[datetime] = mapped_column() start_time: Mapped[datetime] = mapped_column()
num_people: Mapped[int] = mapped_column()
def __repr__(self) -> str: 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") engine = create_engine("sqlite:///scl.db")
@ -152,6 +153,8 @@ with Session(engine) as session:
existing_record.status = status existing_record.status = status
updated_properties.append("status") updated_properties.append("status")
updated_entries.append("Status: {}".format(status)) updated_entries.append("Status: {}".format(status))
if existing_record.num_people != event["numPeople"]:
existing_record.num_people = event["numPeople"]
if updated_properties: if updated_properties:
updated_properties.sort() updated_properties.sort()
@ -366,6 +369,7 @@ with Session(engine) as session:
status=status, status=status,
outage_size=outage_size, outage_size=outage_size,
start_time=start_time, start_time=start_time,
num_people=event["numPeople"]
) )
session.add(new_outage_record) session.add(new_outage_record)
session.commit() session.commit()