Skip to content

Commit e8df18d

Browse files
author
Jongmin Kim
committed
feat: change unwind option in analyze query
Signed-off-by: Jongmin Kim <[email protected]>
1 parent f7bcad8 commit e8df18d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/spaceone/core/model/mongo_model/__init__.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -610,12 +610,7 @@ def _stat_with_unwind(
610610
raise ERROR_DB_QUERY(reason="unwind option should have path key.")
611611

612612
unwind_path = unwind["path"]
613-
unwind_filter = unwind.get("filter")
614-
615-
aggregate = [{"unwind": {"path": unwind_path}}]
616-
617-
if unwind_filter:
618-
aggregate.append({"match": {"filter": unwind_filter}})
613+
aggregate = [{"unwind": unwind}]
619614

620615
# Add project stage
621616
project_fields = []
@@ -1088,6 +1083,11 @@ def _make_aggregate_rules(cls, aggregate):
10881083
if "unwind" in stage:
10891084
rule = cls._make_unwind_rule(stage["unwind"])
10901085
_aggregate_rules.append(rule)
1086+
1087+
if unwind_filter := stage["unwind"].get("filter"):
1088+
rule = cls._make_match_rule({"filter": unwind_filter})
1089+
_aggregate_rules.append(rule)
1090+
10911091
elif "group" in stage:
10921092
rule, group_keys = cls._make_group_rule(stage["group"], _group_keys)
10931093
_aggregate_rules.append(rule)

0 commit comments

Comments
 (0)