Skip to content

Commit

Permalink
fix: Error viewing images in Explore Data page (#936)
Browse files Browse the repository at this point in the history
  • Loading branch information
cecheta authored May 17, 2024
1 parent 392d437 commit 0d12d63
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/backend/batch/utilities/search/azure_search_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,9 @@ def process_results(self, results):
if results is None:
return []
data = [
[json.loads(result["metadata"])["chunk"], result["content"]]
for result in results
# Note that images uploaded with advanced image processing do not have a chunk ID
[json.loads(result["metadata"]).get("chunk", i), result["content"]]
for i, result in enumerate(results)
]
return data

Expand Down
14 changes: 14 additions & 0 deletions code/tests/search_utilities/test_azure_search_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,20 @@ def test_process_results(handler):
assert data[0] == [1, "Content 1"]


def test_process_results_without_chunk(handler):
# given
results = [
{"metadata": "{}", "content": "Content 1"},
{"metadata": "{}", "content": "Content 2"},
]

# when
data = handler.process_results(results)

# then
assert data == [[0, "Content 1"], [1, "Content 2"]]


def test_process_results_null(handler):
# given
results = []
Expand Down

0 comments on commit 0d12d63

Please sign in to comment.