Skip to content

Commit

Permalink
better realtime output
Browse files Browse the repository at this point in the history
  • Loading branch information
the-infinity committed Jan 24, 2025
1 parent c92c028 commit bdbc047
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions webapp/models/source.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,14 @@ class Source(BaseModel):
static_parking_site_error_count: Mapped[int] = mapped_column(Integer(), nullable=False, default=0)
realtime_parking_site_error_count: Mapped[int] = mapped_column(Integer(), nullable=False, default=0)

def to_dict(self, *args, ignore: Optional[list[str]] = None, **kwargs) -> dict:
ignore = ignore or []
if self.static_status in [SourceStatus.PROVISIONED, SourceStatus.DISABLED]:
ignore += ['static_data_updated_at', 'static_parking_site_error_count']
if self.realtime_status in [SourceStatus.PROVISIONED, SourceStatus.DISABLED]:
ignore += ['realtime_data_updated_at', 'realtime_parking_site_error_count']
return super().to_dict(*args, ignore=ignore, **kwargs)

@property
def combined_status(self) -> SourceStatus:
if self.static_status != SourceStatus.ACTIVE or self.realtime_status in [
Expand Down

0 comments on commit bdbc047

Please sign in to comment.