Skip to content

Commit 18630e6

Browse files
author
Jongmin Kim
authored
Merge pull request #82 from whdalsrnt/master
refactor: add option to analyze query
2 parents 5c2a862 + 88c4e63 commit 18630e6

1 file changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1258,8 +1258,8 @@ def _make_date_filter(cls, date_field, key, operator):
12581258

12591259
@classmethod
12601260
def analyze(cls, *args, granularity=None, fields=None, select=None, group_by=None, field_group=None, filter=None,
1261-
filter_or=None, page=None, sort=None, start=None, end=None, date_field='date',
1262-
target='SECONDARY_PREFERRED', **kwargs):
1261+
filter_or=None, page=None, sort=None, start=None, end=None, date_field='date', start_field=None,
1262+
end_field=None, target='SECONDARY_PREFERRED', **kwargs):
12631263

12641264
if fields is None:
12651265
raise ERROR_REQUIRED_PARAMETER(key='fields')
@@ -1275,10 +1275,12 @@ def analyze(cls, *args, granularity=None, fields=None, select=None, group_by=Non
12751275
page_limit = page.get('limit')
12761276

12771277
if start:
1278-
filter += cls._make_date_filter(date_field, start, 'gte')
1278+
start_field = start_field or date_field
1279+
filter += cls._make_date_filter(start_field, start, 'gte')
12791280

12801281
if end:
1281-
filter += cls._make_date_filter(date_field, end, 'lte')
1282+
end_field = end_field or date_field
1283+
filter += cls._make_date_filter(end_field, end, 'lte')
12821284

12831285
group_keys = cls._make_group_keys(group_by, date_field, granularity)
12841286
group_fields = cls._make_group_fields(fields)

0 commit comments

Comments
 (0)