Skip to content

Commit

Permalink
Merge pull request #43 from stackhpc/upstream/wallaby-2023-02-27
Browse files Browse the repository at this point in the history
Synchronise wallaby with upstream
  • Loading branch information
markgoddard authored Feb 27, 2023
2 parents 165f26c + c7851e9 commit 678d955
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
9 changes: 8 additions & 1 deletion cloudkitty/storage/v2/elasticsearch/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,14 @@ def retrieve(self, begin, end, filters, metric_types,

scroll_id = resp['_scroll_id']
self._scroll_ids.add(scroll_id)
total = resp['hits']['total']
total_hits = resp['hits']['total']

if isinstance(total_hits, dict):
LOG.debug("Total hits [%s] is a dict. Therefore, we only extract "
"the 'value' attribute as the total option.", total_hits)
total_hits = total_hits.get("value")

total = total_hits
chunk = resp['hits']['hits']

output = chunk[offset:offset+limit if paginate else len(chunk)]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
fixes:
- |
Fix response format ``total`` for v2 dataframes API. The response for v2
dataframes is ``{"total": 3}``. However, for Elasticsearch search response,
the ``"hits.total"`` in the response body is ``{"value": 3, "relation":
"eq"}``, which does not match the API response schema.

0 comments on commit 678d955

Please sign in to comment.