Skip to content

Commit

Permalink
fix more metrics logic
Browse files Browse the repository at this point in the history
  • Loading branch information
the-infinity committed Jul 18, 2024
1 parent f28e8aa commit be955bb
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 20 deletions.
9 changes: 9 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
# Changelog

## 0.7.5

Released 2024-07-18

### Fixes

* Fix more metrics logic


## 0.7.4

Released 2024-07-18
Expand Down
42 changes: 22 additions & 20 deletions webapp/prometheus_api/prometheus_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,26 +158,28 @@ def get_parking_site_metrics(self) -> list[str]:
parking_site_name=parking_site.name,
)
)
if parking_site.has_realtime_data:
if parking_site.realtime_capacity is None:
continue
parking_site_realtime_capacity.metrics.append(
ParkingSiteMetric(
parking_site_uid=parking_site.original_uid,
source=parking_site.source.uid,
value=parking_site.realtime_capacity,
parking_site_name=parking_site.name,
)
if not parking_site.has_realtime_data:
continue

if parking_site.realtime_capacity is None:
continue
parking_site_realtime_capacity.metrics.append(
ParkingSiteMetric(
parking_site_uid=parking_site.original_uid,
source=parking_site.source.uid,
value=parking_site.realtime_capacity,
parking_site_name=parking_site.name,
)
if parking_site.realtime_free_capacity is None:
continue
parking_site_realtime_free_capacity.metrics.append(
ParkingSiteMetric(
parking_site_uid=parking_site.original_uid,
source=parking_site.source.uid,
value=parking_site.realtime_free_capacity,
parking_site_name=parking_site.name,
)
)
if parking_site.realtime_free_capacity is None:
continue
parking_site_realtime_free_capacity.metrics.append(
ParkingSiteMetric(
parking_site_uid=parking_site.original_uid,
source=parking_site.source.uid,
value=parking_site.realtime_free_capacity,
parking_site_name=parking_site.name,
)
)

return parking_site_static_capacity.to_metrics() + parking_site_realtime_capacity.to_metrics()
return parking_site_static_capacity.to_metrics() + parking_site_realtime_capacity.to_metrics() + parking_site_realtime_free_capacity.to_metrics()

Check failure on line 185 in webapp/prometheus_api/prometheus_handler.py

View workflow job for this annotation

GitHub Actions / lint (3)

Ruff (E501)

webapp/prometheus_api/prometheus_handler.py:185:141: E501 Line too long (153 > 140)

0 comments on commit be955bb

Please sign in to comment.