Selaa lähdekoodia

HUE-3499 [editor] Add an expired status in the query history

Now also do not set all the expired queries to failed.
Romain Rigaux 9 vuotta sitten
vanhempi
commit
3057a1c

+ 10 - 1
desktop/libs/notebook/src/notebook/api.py

@@ -27,7 +27,8 @@ from django.views.decorators.http import require_GET, require_POST
 from desktop.lib.django_util import JsonResponse
 from desktop.models import Document2, Document
 
-from notebook.connectors.base import get_api, Notebook, QueryExpired
+from notebook.connectors.base import get_api, Notebook, QueryExpired,\
+  SessionExpired
 from notebook.decorators import api_error_handler, check_document_access_permission, check_document_modify_permission
 from notebook.github import GithubClient
 from notebook.models import escape_rows
@@ -120,9 +121,17 @@ def check_status(request):
   try:
     response['query_status'] = get_api(request, snippet).check_status(notebook, snippet)
     response['status'] = 0
+  except SessionExpired:
+    response['status'] = 'expired'
+    raise
+  except QueryExpired:
+    response['status'] = 'expired'
+    raise
   finally:
     if response['status'] == 0 and snippet['status'] != response['query_status']:
       status = response['query_status']['status']
+    elif response['status'] == 'expired':
+      status = 'expired'
     else:
       status = 'failed'
     nb_doc = Document2.objects.get(id=notebook['id'])

+ 1 - 1
desktop/libs/notebook/src/notebook/templates/editor_components.mako

@@ -464,7 +464,7 @@ ${ hueIcons.symbols() }
               <tr class="pointer" data-bind="click: function() { if (getSelection().toString().length == 0) { $root.openNotebook(uuid) } }">
                 <td style="width: 100px" class="muted" data-bind="style:{'border-top-width': $index()==0 ? '0' : ''}"><span data-bind="text: moment(lastExecuted).fromNow(), attr: {title: moment(lastExecuted).format('LLL')}"></span></td>
                 <td style="width: 25px" class="muted" data-bind="style:{'border-top-width': $index()==0 ? '0' : ''}">
-                  <i class="fa fa-fw fa-bolt inactive-action" data-bind="css: {'fa-fighter-jet': status == 'running', 'fa-cloud-download': status == 'available'}, attr: {'title': status}"></i>
+                  <i class="fa fa-fw fa-bolt inactive-action" data-bind="css: {'fa-unlink': status == 'expired', 'fa-fighter-jet': status == 'running', 'fa-cloud-download': status == 'available'}, attr: {'title': status}"></i>
                 </td>
                 <td data-bind="style:{'border-top-width': $index()==0 ? '0' : ''}"><code data-bind="text: query" class="history-item"></code></td>
               </tr>