Skip to content

Commit

Permalink
Finalize ability to trigger jobs from UI
Browse files Browse the repository at this point in the history
  • Loading branch information
ingalls committed Oct 1, 2021
1 parent e13e8d6 commit 6d216fa
Showing 1 changed file with 9 additions and 29 deletions.
38 changes: 9 additions & 29 deletions api/lib/schedule.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@ class Schedule {
static async event(pool, event) {
if (event.type === 'collect') {
await Schedule.collect();
} else if (event.type === 'fabric') {
await Schedule.fabric();
} else if (event.type === 'sources') {
await Schedule.sources(pool);
} else if (['fabric', 'collect', 'sources'].includes(event.type)) {
await Schedule.batch(event.type);
} else if (event.type === 'close') {
await Schedule.close(pool);
} else if (event.type === 'level') {
Expand All @@ -32,23 +30,17 @@ class Schedule {
}
}

static async collect() {
/**
* Generic function for triggering a batch job
* @param {String} type Type of batch job to trigger
*/
static async batch(type) {
try {
return await batch.trigger({
type: 'collect'
type: type
});
} catch (err) {
throw new Err(500, err, 'failed to submit collect job to batch');
}
}

static async collect() {
try {
return await batch.trigger({
type: 'fabric'
});
} catch (err) {
throw new Err(500, err, 'failed to submit fabric job to batch');
throw new Err(500, err, 'Failed to submit job to batch');
}
}

Expand All @@ -62,18 +54,6 @@ class Schedule {
}
}

static async sources(pool) {
await JobError.clear(pool);

try {
return await batch.trigger({
type: 'sources'
});
} catch (err) {
throw new Err(500, err, 'failed to submit sources job to batch');
}
}

static async close(pool) {
// TODO Close old run/jobs

Expand Down

0 comments on commit 6d216fa

Please sign in to comment.