Skip to content
Snippets Groups Projects
Verified Commit 476d1f54 authored by David Hoese's avatar David Hoese
Browse files

Fix influxdbv2 results not being ordered properly

parent 07a9e356
No related branches found
No related tags found
No related merge requests found
......@@ -337,6 +337,26 @@ def test_shorthand_one_symbol_json_column(client):
assert len(res["results"]["timestamps"]) == 9
@pytest.mark.usefixtures("influxdb_3_symbols_9_values")
def test_shorthand_two_symbols_json_column_order_check(client):
res1 = _query_with_symbols(client, "air_temp:rel_hum:wind_speed")
res2 = _query_with_symbols(client, "rel_hum:air_temp:wind_speed")
assert res1["results"]["data"]["air_temp"] == res2["results"]["data"]["air_temp"]
assert res1["results"]["data"]["rel_hum"] == res2["results"]["data"]["rel_hum"]
def _query_with_symbols(client, symbols: str) -> dict:
res = client.get(f"/api/data.json?site=aoss&inst=tower&symbols={symbols}&begin=-00:10:00&order=column")
res = json.loads(res.data.decode())
assert res["code"] == 200
assert res["num_results"] == 9
for symbol in symbols.split(":"):
assert symbol in res["results"]["data"]
assert len(res["results"]["data"][symbol]) == 9
assert len(res["results"]["timestamps"]) == 9
return res
@pytest.mark.parametrize(
"symbols",
[
......
......@@ -89,6 +89,8 @@ class QueryHandler:
else:
data_frame = frames_for_inst[0]
data_frame = data_frame.drop(columns=["site", "inst"])
# get dataframe into the same order that was requested
data_frame = data_frame[symbol_names]
# "_time" should already be set as the index so we don't need to rename it
new_column_names = [f"{site}.{inst}.{col_name}" for col_name in data_frame.columns]
data_frame.columns = new_column_names
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment