Skip to content

Commit

Permalink
aggregations: turn agg query results into dictionaries
Browse files Browse the repository at this point in the history
* because we're reusing parts of the aggregation query results directly,
  and per default they're wrapped in DSL objects (e.g. AttrList) that
  aren't JSON-serializable
* see: elastic/elasticsearch-dsl-py#913
  • Loading branch information
max-moser committed Mar 30, 2023
1 parent 70570f0 commit 95082d7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion invenio_stats/aggregations.py
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,8 @@ def agg_iter(self, dt):
ignore_cache=True,
)
for aggregation in results.aggregations["terms"].buckets:
doc = aggregation.top_hit.hits.hits[0]["_source"]
doc = aggregation.top_hit.hits.hits[0]["_source"].to_dict()
aggregation = aggregation.to_dict()
interval_date = datetime.strptime(
doc["timestamp"], "%Y-%m-%dT%H:%M:%S"
).replace(**dict.fromkeys(INTERVAL_ROUNDING[self.interval], 0))
Expand Down

0 comments on commit 95082d7

Please sign in to comment.