Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
M
MetObsAPI
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
MetObs
MetObsAPI
Commits
476d1f54
Verified
Commit
476d1f54
authored
2 years ago
by
David Hoese
Browse files
Options
Downloads
Patches
Plain Diff
Fix influxdbv2 results not being ordered properly
parent
07a9e356
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
metobsapi/tests/test_data_api.py
+20
-0
20 additions, 0 deletions
metobsapi/tests/test_data_api.py
metobsapi/util/query_influx.py
+2
-0
2 additions, 0 deletions
metobsapi/util/query_influx.py
with
22 additions
and
0 deletions
metobsapi/tests/test_data_api.py
+
20
−
0
View file @
476d1f54
...
...
@@ -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
"
,
[
...
...
This diff is collapsed.
Click to expand it.
metobsapi/util/query_influx.py
+
2
−
0
View file @
476d1f54
...
...
@@ -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
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment