Skip to content

Commit

Permalink
fix: Get current api usage InfluxDB query (#3846)
Browse files Browse the repository at this point in the history
  • Loading branch information
zachaysan authored Apr 29, 2024
1 parent d4c9173 commit 905c9fb
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions api/app_analytics/influxdb_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,6 +341,7 @@ def get_current_api_usage(organisation_id: int, date_range: str) -> int:
),
drop_columns=("_start", "_stop", "_time"),
extra='|> sum() \
|> group() \
|> sort(columns: ["_value"], desc: true) ',
)

Expand All @@ -349,10 +350,7 @@ def get_current_api_usage(organisation_id: int, date_range: str) -> int:
if len(result.records) == 0:
return 0

# There should only be one matching result due to the
# sum part of the query.
assert len(result.records) == 1
return result.records[0].get_value()
return sum(r.get_value() for r in result.records)

return 0

Expand Down

0 comments on commit 905c9fb

Please sign in to comment.