Skip to content

Commit

Permalink
Merge pull request #149 from whdalsrnt/master
Browse files Browse the repository at this point in the history
feat: add unwind option to analyze query
  • Loading branch information
whdalsrnt authored Jun 9, 2024
2 parents 7e665b7 + 37a742d commit 7dc1980
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/spaceone/core/model/mongo_model/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -1493,6 +1493,7 @@ def analyze(
sort=None,
start=None,
end=None,
unwind=None,
date_field="date",
date_field_format="%Y-%m-%d",
reference_filter=None,
Expand Down Expand Up @@ -1526,10 +1527,17 @@ def analyze(
group_keys = cls._make_group_keys(group_by, date_field, granularity)
group_fields = cls._make_group_fields(fields)

aggregate = []

if unwind:
aggregate.append({"unwind": unwind})

aggregate.append({"group": {"keys": group_keys, "fields": group_fields}})

query = {
"filter": filter,
"filter_or": filter_or,
"aggregate": [{"group": {"keys": group_keys, "fields": group_fields}}],
"aggregate": aggregate,
"target": target,
"allow_disk_use": allow_disk_use,
"reference_filter": reference_filter,
Expand Down

0 comments on commit 7dc1980

Please sign in to comment.