feat(core): real time progress update for runs
This commit is contained in:
@@ -48,6 +48,7 @@ interface InterpreterOptions {
|
|||||||
debugMessage: (msg: string) => void,
|
debugMessage: (msg: string) => void,
|
||||||
setActionType: (type: string) => void,
|
setActionType: (type: string) => void,
|
||||||
incrementScrapeListIndex: () => void,
|
incrementScrapeListIndex: () => void,
|
||||||
|
progressUpdate: (current: number, total: number, percentage: number) => void,
|
||||||
}>
|
}>
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -84,6 +85,10 @@ export default class Interpreter extends EventEmitter {
|
|||||||
|
|
||||||
private scrapeListCounter: number = 0;
|
private scrapeListCounter: number = 0;
|
||||||
|
|
||||||
|
private totalActions: number = 0;
|
||||||
|
|
||||||
|
private executedActions: number = 0;
|
||||||
|
|
||||||
constructor(workflow: WorkflowFile, options?: Partial<InterpreterOptions>) {
|
constructor(workflow: WorkflowFile, options?: Partial<InterpreterOptions>) {
|
||||||
super();
|
super();
|
||||||
this.workflow = workflow.workflow;
|
this.workflow = workflow.workflow;
|
||||||
@@ -1596,6 +1601,17 @@ export default class Interpreter extends EventEmitter {
|
|||||||
|
|
||||||
workflowCopy.splice(actionId, 1);
|
workflowCopy.splice(actionId, 1);
|
||||||
console.log(`Action with ID ${action.id} removed from the workflow copy.`);
|
console.log(`Action with ID ${action.id} removed from the workflow copy.`);
|
||||||
|
|
||||||
|
this.executedActions++;
|
||||||
|
const percentage = Math.round((this.executedActions / this.totalActions) * 100);
|
||||||
|
|
||||||
|
if (this.options.debugChannel?.progressUpdate) {
|
||||||
|
this.options.debugChannel.progressUpdate(
|
||||||
|
this.executedActions,
|
||||||
|
this.totalActions,
|
||||||
|
percentage
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// const newSelectors = this.getPreviousSelectors(workflow, actionId);
|
// const newSelectors = this.getPreviousSelectors(workflow, actionId);
|
||||||
// const newSelectors = this.getSelectors(workflowCopy);
|
// const newSelectors = this.getSelectors(workflowCopy);
|
||||||
@@ -1686,6 +1702,13 @@ export default class Interpreter extends EventEmitter {
|
|||||||
*/
|
*/
|
||||||
this.initializedWorkflow = Preprocessor.initWorkflow(this.workflow, params);
|
this.initializedWorkflow = Preprocessor.initWorkflow(this.workflow, params);
|
||||||
|
|
||||||
|
this.totalActions = this.initializedWorkflow.length;
|
||||||
|
this.executedActions = 0;
|
||||||
|
|
||||||
|
if (this.options.debugChannel?.progressUpdate) {
|
||||||
|
this.options.debugChannel.progressUpdate(0, this.totalActions, 0);
|
||||||
|
}
|
||||||
|
|
||||||
await this.ensureScriptsLoaded(page);
|
await this.ensureScriptsLoaded(page);
|
||||||
|
|
||||||
this.stopper = () => {
|
this.stopper = () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user