Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions src/spaceone/core/model/mongo_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -610,12 +610,7 @@ def _stat_with_unwind(
raise ERROR_DB_QUERY(reason="unwind option should have path key.")

unwind_path = unwind["path"]
unwind_filter = unwind.get("filter")

aggregate = [{"unwind": {"path": unwind_path}}]

if unwind_filter:
aggregate.append({"match": {"filter": unwind_filter}})
aggregate = [{"unwind": unwind}]

# Add project stage
project_fields = []
Expand Down Expand Up @@ -1088,6 +1083,11 @@ def _make_aggregate_rules(cls, aggregate):
if "unwind" in stage:
rule = cls._make_unwind_rule(stage["unwind"])
_aggregate_rules.append(rule)

if unwind_filter := stage["unwind"].get("filter"):
rule = cls._make_match_rule({"filter": unwind_filter})
_aggregate_rules.append(rule)

elif "group" in stage:
rule, group_keys = cls._make_group_rule(stage["group"], _group_keys)
_aggregate_rules.append(rule)
Expand Down
Loading