|
@@ -425,6 +425,7 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
|
|
|
elif widget_type == 'document-widget':
|
|
elif widget_type == 'document-widget':
|
|
|
# SQL query, 1 solr widget
|
|
# SQL query, 1 solr widget
|
|
|
if collection['selectedDocument'].get('uuid'):
|
|
if collection['selectedDocument'].get('uuid'):
|
|
|
|
|
+ properties['statementUuid'] = collection['selectedDocument'].get('uuid')
|
|
|
doc = Document2.objects.get_by_uuid(user=user, uuid=collection['selectedDocument']['uuid'], perm_type='read')
|
|
doc = Document2.objects.get_by_uuid(user=user, uuid=collection['selectedDocument']['uuid'], perm_type='read')
|
|
|
snippets = doc.data_dict.get('snippets', [])
|
|
snippets = doc.data_dict.get('snippets', [])
|
|
|
properties['result'] = {'handle': {'statement_id': 0, 'statements_count': 1, 'previous_statement_hash': hashlib.sha224(str(uuid.uuid4())).hexdigest()}}
|
|
properties['result'] = {'handle': {'statement_id': 0, 'statements_count': 1, 'previous_statement_hash': hashlib.sha224(str(uuid.uuid4())).hexdigest()}}
|
|
@@ -432,22 +433,8 @@ def _create_facet(collection, user, facet_id, facet_label, facet_field, widget_t
|
|
|
table_metadata = get_api(MockRequest(user, '""'), snippets[0]).autocomplete({'source': 'query', 'type': snippets[0]['type']}, doc.id)
|
|
table_metadata = get_api(MockRequest(user, '""'), snippets[0]).autocomplete({'source': 'query', 'type': snippets[0]['type']}, doc.id)
|
|
|
template['fieldsAttributes'] = [Collection2._make_gridlayout_header_field(field) for field in table_metadata['extended_columns']]
|
|
template['fieldsAttributes'] = [Collection2._make_gridlayout_header_field(field) for field in table_metadata['extended_columns']]
|
|
|
properties['engine'] = snippets[0]['type']
|
|
properties['engine'] = snippets[0]['type']
|
|
|
- if snippets[0]['result']['handle']:
|
|
|
|
|
- handle = snippets[0]['result']['handle']
|
|
|
|
|
- properties['result']['handle'].update({
|
|
|
|
|
- 'statement_id': handle['statement_id'],
|
|
|
|
|
- 'statements_count': handle['statements_count']
|
|
|
|
|
- })
|
|
|
|
|
- properties['statement'] = snippets[0]['statement_raw']
|
|
|
|
|
- else:
|
|
|
|
|
- properties['statement'] = ''
|
|
|
|
|
-
|
|
|
|
|
- if collection['selectedDocument'].get('statement_id'):
|
|
|
|
|
- properties['result']['handle']['statement_id'] = collection['selectedDocument'].get('statement_id')
|
|
|
|
|
- properties['result']['handle']['statements_count'] = properties['result']['handle'].get('statements_count', collection['selectedDocument'].get('statement_id'))
|
|
|
|
|
- else: # Demo data for now
|
|
|
|
|
- properties['statement'] = 'select * from customers'
|
|
|
|
|
- properties['result'] = {'handle': {}}
|
|
|
|
|
|
|
+ else:
|
|
|
|
|
+ properties['statementUuid'] = ''
|
|
|
|
|
|
|
|
properties['uuid'] = facet_field
|
|
properties['uuid'] = facet_field
|
|
|
properties['facets'] = [{'canRange': False, 'field': 'blank', 'limit': 10, 'mincount': 0, 'sort': 'desc', 'aggregate': {'function': 'count'}, 'isDate': False, 'type': 'field'}]
|
|
properties['facets'] = [{'canRange': False, 'field': 'blank', 'limit': 10, 'mincount': 0, 'sort': 'desc', 'aggregate': {'function': 'count'}, 'isDate': False, 'type': 'field'}]
|