Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Set early return when influxdb range is empty #4274

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions api/app_analytics/influxdb_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ def influx_query_manager(
extra: str = "",
bucket: str = read_bucket,
):
# Influx throws an error for an empty range, so just return a list.
if date_start == "-0d" and date_stop == "now()":
return []

query_api = influxdb_client.query_api()
drop_columns_input = str(list(drop_columns)).replace("'", '"')

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -440,3 +440,14 @@ def test_get_top_organisations_value_error(
# The wrongly typed data does not stop the remaining data
# from being returned.
assert dataset == {456: 43}


def test_early_return_for_empty_range_for_influx_query_manager() -> None:
# When
results = InfluxDBWrapper.influx_query_manager(
date_start="-0d",
date_stop="now()",
)

# Then
assert results == []
Loading