fix: 命令记录-导出选择项命令:却导出了所有命令

pull/7081/head
feng626 2021-10-26 16:23:58 +08:00
parent ba6c49e62b
commit 8a413563be
1 changed files with 15 additions and 3 deletions

View File

@ -131,10 +131,13 @@ class CommandStore():
index=self.index, doc_type=self.doc_type, body=body, from_=from_, size=size, index=self.index, doc_type=self.doc_type, body=body, from_=from_, size=size,
sort=sort sort=sort
) )
source_data = []
for item in data['hits']['hits']:
if item:
item['_source'].update({'id': item['_id']})
source_data.append(item['_source'])
return AbstractSessionCommand.from_multi_dict( return AbstractSessionCommand.from_multi_dict(source_data)
[item['_source'] for item in data['hits']['hits'] if item]
)
def count(self, **query): def count(self, **query):
body = self.get_query_body(**query) body = self.get_query_body(**query)
@ -160,11 +163,16 @@ class CommandStore():
new_kwargs[k] = str(v) if isinstance(v, UUID) else v new_kwargs[k] = str(v) if isinstance(v, UUID) else v
kwargs = new_kwargs kwargs = new_kwargs
index_in_field = 'id__in'
exact_fields = self.exact_fields exact_fields = self.exact_fields
match_fields = self.match_fields match_fields = self.match_fields
match = {} match = {}
exact = {} exact = {}
index = {}
if index_in_field in kwargs:
index['values'] = kwargs[index_in_field]
for k, v in kwargs.items(): for k, v in kwargs.items():
if k in exact_fields: if k in exact_fields:
@ -221,6 +229,10 @@ class CommandStore():
'timestamp': timestamp_range 'timestamp': timestamp_range
} }
} }
] + [
{
'ids': {k: v}
} for k, v in index.items()
] ]
} }
}, },