Skip to content

Commit

Permalink
Fix parsing of FT.PROFILE result (#3063)
Browse files Browse the repository at this point in the history
* Fix parsing of ft.profile result

* test
  • Loading branch information
dvora-h committed Feb 25, 2024
1 parent c1a881e commit 7c13191
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
5 changes: 5 additions & 0 deletions redis/commands/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,11 @@ def parse_list_to_dict(response):
for i in range(0, len(response), 2):
if isinstance(response[i], list):
res["Child iterators"].append(parse_list_to_dict(response[i]))
try:
if isinstance(response[i + 1], list):
res["Child iterators"].append(parse_list_to_dict(response[i + 1]))
except IndexError:
pass
elif isinstance(response[i + 1], list):
res["Child iterators"] = [parse_list_to_dict(response[i + 1])]
else:
Expand Down
2 changes: 2 additions & 0 deletions tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@ def test_parse_to_dict():
"Child iterators",
["Type", "bar", "Time", "0.0729", "Counter", 3],
["Type", "barbar", "Time", "0.058", "Counter", 3],
["Type", "barbarbar", "Time", "0.0234", "Counter", 3],
],
],
]
Expand All @@ -49,6 +50,7 @@ def test_parse_to_dict():
"Child iterators": [
{"Counter": 3.0, "Time": 0.0729, "Type": "bar"},
{"Counter": 3.0, "Time": 0.058, "Type": "barbar"},
{"Counter": 3.0, "Time": 0.0234, "Type": "barbarbar"},
],
"Counter": 3.0,
"Time": 0.2089,
Expand Down

0 comments on commit 7c13191

Please sign in to comment.