diff --git a/invenio_stats/aggregations.py b/invenio_stats/aggregations.py index 737cea2..21a1b17 100644 --- a/invenio_stats/aggregations.py +++ b/invenio_stats/aggregations.py @@ -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))