Skip to content

Commit 2cb6c2a

Browse files
committed
handle geographies aggregation
1 parent c1d792a commit 2cb6c2a

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

api/views/paginated_elastic_view.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,20 @@ def get(self, request: HttpRequest) -> Response:
139139
for agg in formats_agg:
140140
aggregations["formats"][agg["key"]] = agg["doc_count"]
141141

142+
# Handle geographies aggregation (now comes as "geographies.raw")
143+
if "geographies.raw" in aggregations:
144+
geographies_agg = aggregations["geographies.raw"]["buckets"]
145+
aggregations.pop("geographies.raw")
146+
aggregations["geographies"] = {}
147+
for agg in geographies_agg:
148+
aggregations["geographies"][agg["key"]] = agg["doc_count"]
149+
elif "geographies" in aggregations:
150+
geographies_agg = aggregations["geographies"]["buckets"]
151+
aggregations.pop("geographies")
152+
aggregations["geographies"] = {}
153+
for agg in geographies_agg:
154+
aggregations["geographies"][agg["key"]] = agg["doc_count"]
155+
142156
if "status" in aggregations:
143157
status_agg = aggregations["status"]["buckets"]
144158
aggregations.pop("status")

0 commit comments

Comments
 (0)