Skip to content

Commit 7993796

Browse files
author
Jongmin Kim
committed
feat: apply hint option to analyze query
Signed-off-by: Jongmin Kim <whdalsrnt@megazone.com>
1 parent 6ab5f11 commit 7993796

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1147,18 +1147,15 @@ def _stat_aggregate(cls, vos, aggregate, page, hint, allow_disk_use, return_type
11471147

11481148
pipeline.append({"$limit": limit})
11491149

1150+
options = {}
11501151
if allow_disk_use:
11511152
_LOGGER.debug(f"[_stat_aggregate] allow_disk_use: {allow_disk_use}")
1153+
options["allowDiskUse"] = True
11521154

1153-
if hint:
1154-
cursor = vos.aggregate(pipeline, hint=hint, allowDiskUse=True)
1155-
else:
1156-
cursor = vos.aggregate(pipeline, allowDiskUse=True)
1157-
else:
1158-
if hint:
1159-
cursor = vos.aggregate(pipeline, hint=hint)
1160-
else:
1161-
cursor = vos.aggregate(pipeline)
1155+
if hint:
1156+
options["hint"] = hint
1157+
1158+
cursor = vos.aggregate(pipeline, **options)
11621159

11631160
if return_type == "cursor":
11641161
return cursor
@@ -1518,6 +1515,7 @@ def analyze(
15181515
date_field_format="%Y-%m-%d",
15191516
reference_filter=None,
15201517
target="SECONDARY_PREFERRED",
1518+
hint=None,
15211519
allow_disk_use=False,
15221520
return_type="dict",
15231521
**kwargs,
@@ -1560,6 +1558,7 @@ def analyze(
15601558
"filter_or": filter_or,
15611559
"aggregate": aggregate,
15621560
"target": target,
1561+
"hint": hint,
15631562
"allow_disk_use": allow_disk_use,
15641563
"return_type": return_type,
15651564
"reference_filter": reference_filter,

0 commit comments

Comments
 (0)