@@ -10,6 +10,9 @@ Page.Job = class Job extends Page.PageUtils {
1010 // called once at page load
1111 this . colors = app . colors ;
1212 this . header_bar_width = 175 ;
13+
14+ // throttle this API call for dealing with heavy jobs
15+ this . getWorkflowQueueSummaryDebounce = debounce ( this . getWorkflowQueueSummary . bind ( this ) , 1000 ) ;
1316 }
1417
1518 onActivate ( args ) {
@@ -1061,7 +1064,7 @@ Page.Job = class Job extends Page.PageUtils {
10611064 this . decorateWorkflowNodes ( ) ;
10621065
10631066 // we have to fetch queued job information separately
1064- if ( ! this . job . final ) this . getWorkflowQueueSummary ( ) ;
1067+ if ( ! this . job . final ) this . getWorkflowQueueSummaryDebounce ( ) ;
10651068
10661069 // show orange notification if sus level has increased
10671070 if ( ! this . lastSuspendedCount ) this . lastSuspendedCount = 0 ;
@@ -1235,14 +1238,18 @@ Page.Job = class Job extends Page.PageUtils {
12351238 getWorkflowQueueSummary ( ) {
12361239 // fetch summary of queued job counts per node
12371240 var self = this ;
1241+ if ( ! self . active || ! self . job || self . job . final ) return ; // sanity checks
1242+
12381243 var workflow = this . job . workflow ;
12391244 var $cont = this . wfGetContainer ( ) ;
1245+ if ( ! workflow || ! workflow . nodes || ! $cont . length ) return ; // more sanity checks
12401246
12411247 app . api . get ( 'app/get_workflow_job_summary' , { 'workflow.job' : this . job . id , state : 'queued' } , function ( resp ) {
1242- if ( ! self . active || ! resp || ! resp . nodes || ! self . job || self . job . final ) return ; // sanity checks
1248+ if ( ! self . active || ! resp || ! resp . nodes || ! self . job || self . job . final ) return ; // even more sanity checks
12431249
12441250 workflow . nodes . filter ( function ( node ) { return ! ! node . type . match ( / ^ ( e v e n t | j o b ) $ / ) ; } ) . forEach ( function ( node ) {
12451251 var $div = $cont . find ( `#d_wfn_${ node . id } > .wf_active_bar > .wf_active_widget.wf_queued` ) ;
1252+ if ( ! $div . length ) return ; // sanity
12461253 var count = resp . nodes [ node . id ] || 0 ;
12471254
12481255 if ( count ) $div . show ( ) . html ( `<i class="mdi mdi-tray-full"></i><span>${ commify ( count ) } </span>` ) ;
0 commit comments