Переглянути джерело

HUE-9262 [editor] Set the lastExecuted timestamp in editor v2

Johan Ahlen 5 роки тому
батько
коміт
5e423f4e9a

+ 9 - 3
desktop/core/src/desktop/js/apps/notebook2/execution/executable.js

@@ -92,11 +92,15 @@ export default class Executable {
     return (this.executeEnded || Date.now()) - this.executeStarted;
   }
 
-  notify() {
+  notify(sync) {
     window.clearTimeout(this.notifyThrottle);
-    this.notifyThrottle = window.setTimeout(() => {
+    if (sync) {
       huePubSub.publish(EXECUTABLE_UPDATED_EVENT, this);
-    }, 1);
+    } else {
+      this.notifyThrottle = window.setTimeout(() => {
+        huePubSub.publish(EXECUTABLE_UPDATED_EVENT, this);
+      }, 1);
+    }
   }
 
   isReady() {
@@ -165,6 +169,7 @@ export default class Executable {
 
     this.setStatus(EXECUTION_STATUS.running);
     this.setProgress(0);
+    this.notify(true);
 
     try {
       hueAnalytics.log(
@@ -398,6 +403,7 @@ export default class Executable {
       id: id || UUID(),
       statement_raw: statement,
       statement: statement,
+      lastExecuted: this.executeStarted,
       variables: [],
       compute: this.executor.compute(),
       namespace: this.executor.namespace(),

+ 2 - 0
desktop/core/src/desktop/js/apps/notebook2/snippet.js

@@ -1055,6 +1055,7 @@ export default class Snippet {
 
   updateFromExecutable(executable) {
     if (executable) {
+      this.lastExecuted(executable.executeStarted);
       if (
         executable.status === EXECUTION_STATUS.available ||
         executable.status === EXECUTION_STATUS.failed ||
@@ -1436,6 +1437,7 @@ export default class Snippet {
       statementType: this.statementType(),
       statement: this.statement(),
       aceCursorPosition: this.aceCursorPosition(),
+      lastExecuted: this.lastExecuted(),
       statementPath: this.statementPath(),
       associatedDocumentUuid: this.associatedDocumentUuid(),
       properties: komapping.toJS(this.properties), // TODO: Drop komapping