Browse Source

HUE-8758 [connector] Save connector id of saved and history queries

Romain 5 years ago
parent
commit
16657f22eb
1 changed files with 9 additions and 2 deletions
  1. 9 2
      desktop/libs/notebook/src/notebook/api.py

+ 9 - 2
desktop/libs/notebook/src/notebook/api.py

@@ -449,7 +449,10 @@ def get_logs(request):
   jobs = db.get_jobs(notebook, snippet, full_log)
   jobs = db.get_jobs(notebook, snippet, full_log)
 
 
   response['logs'] = logs.strip()
   response['logs'] = logs.strip()
-  response['progress'] = min(db.progress(notebook, snippet, logs=full_log), 99) if snippet['status'] != 'available' and snippet['status'] != 'success' else 100
+  response['progress'] = min(
+      db.progress(notebook, snippet, logs=full_log),
+      99
+    ) if snippet['status'] != 'available' and snippet['status'] != 'success' else 100
   response['jobs'] = jobs
   response['jobs'] = jobs
   response['isFullLogs'] = db.get_log_is_full_log(notebook, snippet)
   response['isFullLogs'] = db.get_log_is_full_log(notebook, snippet)
   response['status'] = 0
   response['status'] = 0
@@ -483,6 +486,8 @@ def _save_notebook(notebook, user):
   notebook['id'] = notebook_doc.id
   notebook['id'] = notebook_doc.id
   _clear_sessions(notebook)
   _clear_sessions(notebook)
   notebook_doc1 = notebook_doc._get_doc1(doc2_type=notebook_type)
   notebook_doc1 = notebook_doc._get_doc1(doc2_type=notebook_type)
+  if ENABLE_CONNECTORS.get():
+    notebook_doc.connector_id = int(notebook['type'])
   notebook_doc.update_data(notebook)
   notebook_doc.update_data(notebook)
   notebook_doc.search = _get_statement(notebook)
   notebook_doc.search = _get_statement(notebook)
   notebook_doc.name = notebook_doc1.name = notebook['name']
   notebook_doc.name = notebook_doc1.name = notebook['name']
@@ -528,7 +533,7 @@ def _historify(notebook, user):
       type=query_type,
       type=query_type,
       owner=user,
       owner=user,
       is_history=True,
       is_history=True,
-      is_managed=is_managed
+      is_managed=is_managed,
     )
     )
 
 
   # Link history of saved query
   # Link history of saved query
@@ -548,6 +553,8 @@ def _historify(notebook, user):
 
 
   notebook['uuid'] = history_doc.uuid
   notebook['uuid'] = history_doc.uuid
   _clear_sessions(notebook)
   _clear_sessions(notebook)
+  if ENABLE_CONNECTORS.get():
+    history_doc.connector_id = int(notebook['type'])
   history_doc.update_data(notebook)
   history_doc.update_data(notebook)
   history_doc.search = _get_statement(notebook)
   history_doc.search = _get_statement(notebook)
   history_doc.save()
   history_doc.save()