Skip to content

Commit 654f733

Browse files
committed
Bug Fix: Improve behavior of job/workflow detail page with large amounts of queued sub-jobs.
- Prevent API bashing on get_workflow_job_summary - Limit workflow job table to display up to N (items_per_page) items while job is in progress
1 parent d8a9311 commit 654f733

1 file changed

Lines changed: 18 additions & 1 deletion

File tree

htdocs/js/pages/Job.class.js

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ Page.Job = class Job extends Page.PageUtils {
1414
// throttle this API call for dealing with heavy jobs
1515
this.getWorkflowQueueSummaryDebounce = debounce( this.getWorkflowQueueSummary.bind(this), 1000 );
1616
this.getAdditionalJobsDebounce = debounce( this.getAdditionalJobs.bind(this), 1000 );
17+
this.renderWorkflowJobsDebounce = debounce( this.renderWorkflowJobs.bind(this), 1000 );
1718
}
1819

1920
onActivate(args) {
@@ -1013,6 +1014,13 @@ Page.Job = class Job extends Page.PageUtils {
10131014
empty_msg: 'No workflow jobs found.'
10141015
};
10151016

1017+
// sanity chop (while job is in progress)
1018+
if (!this.job.final && (rows.length > config.items_per_page)) {
1019+
var chopped = rows.length - config.items_per_page;
1020+
rows.splice( config.items_per_page );
1021+
grid_args.below = `<ul class="grid_row_more"><div style="grid-column: 1 / -1;">(${commify(chopped)} more ${pluralize('job', chopped)} hidden until workflow completion.)</div></ul>`;
1022+
}
1023+
10161024
html += this.getBasicGrid( grid_args, function(job, idx) {
10171025
var actions = [];
10181026
var tds = [];
@@ -1273,7 +1281,11 @@ Page.Job = class Job extends Page.PageUtils {
12731281
var $cont = this.wfGetContainer();
12741282
if (!workflow || !workflow.nodes || !$cont.length) return; // more sanity checks
12751283

1284+
if (this.wjsInProgress) return; // only allow one of these in flight at a time
1285+
this.wjsInProgress = true;
1286+
12761287
app.api.get( 'app/get_workflow_job_summary', { 'workflow.job': this.job.id, state: 'queued' }, function(resp) {
1288+
self.wjsInProgress = false;
12771289
if (!self.active || !resp || !resp.nodes || !self.job || self.job.final) return; // even more sanity checks
12781290

12791291
workflow.nodes.filter( function(node) { return !!node.type.match(/^(event|job)$/); } ).forEach( function(node) {
@@ -1284,6 +1296,10 @@ Page.Job = class Job extends Page.PageUtils {
12841296
if (count) $div.show().html( `<i class="mdi mdi-tray-full"></i><span>${commify(count)}</span>` );
12851297
else $div.hide().html('');
12861298
} );
1299+
},
1300+
function() {
1301+
// suppress error
1302+
self.wjsInProgress = false;
12871303
}); // api.get
12881304
}
12891305

@@ -3269,7 +3285,7 @@ Page.Job = class Job extends Page.PageUtils {
32693285
}
32703286

32713287
// for workflows, if jobs changed, redraw our special table
3272-
if (this.isWorkflow && data.jobsChanged) this.renderWorkflowJobs();
3288+
if (this.isWorkflow && data.jobsChanged) this.renderWorkflowJobsDebounce();
32733289

32743290
// if jobs changed, update suspension status
32753291
if (data.jobsChanged) this.updateSuspensionStatus();
@@ -3364,6 +3380,7 @@ Page.Job = class Job extends Page.PageUtils {
33643380
delete this.slides;
33653381
delete this.slideIdx;
33663382
delete this.files;
3383+
delete this.wjsInProgress;
33673384

33683385
// destroy charts if applicable
33693386
if (this.charts) {

0 commit comments

Comments
 (0)