diff --git a/direct_indexing/custom_fields/currency_aggregation.py b/direct_indexing/custom_fields/currency_aggregation.py index 7ab6ecb94..eda7de8cc 100644 --- a/direct_indexing/custom_fields/currency_aggregation.py +++ b/direct_indexing/custom_fields/currency_aggregation.py @@ -350,6 +350,13 @@ def get_child_aggregations(dba, aggregation_fields): # {MONGO_UNWIND: "$related-activity"}, {"$unwind": "$related-activity"}, {"$match": {"related-activity.type": 1}}, + {'$group': { + '_id': '$_id', + 'uniqueActivity': { + '$first': '$$ROOT' + } + }}, + {'$replaceRoot': {'newRoot': '$uniqueActivity'}}, {"$group": group_object} # {MONGO_GROUP: group_object} ]))