Skip to content

Commit

Permalink
fix: batch service does not correctly include properties to report ba…
Browse files Browse the repository at this point in the history
…tch status
  • Loading branch information
Codeneos committed Apr 29, 2024
1 parent 758de02 commit e331d01
Show file tree
Hide file tree
Showing 6 changed files with 108 additions and 66 deletions.
2 changes: 1 addition & 1 deletion packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@
"@vlocode/util": "workspace:*",
"chalk": "^4.1.1",
"globby": "^11.0.4",
"luxon": "^3.4.0",
"luxon": "^3.4.4",
"memfs": "^3.2.2",
"minimatch": "^9.0.3",
"reflect-metadata": "^0.1.13",
Expand Down
2 changes: 1 addition & 1 deletion packages/salesforce/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@
"fs-extra": "^11.0",
"jsforce": "1.11.0",
"jszip": "^3.7.0",
"luxon": "^3.4.0",
"luxon": "^3.4.4",
"tough-cookie": "^4.1.2"
},
"publisher": "curlybracket",
Expand Down
45 changes: 27 additions & 18 deletions packages/salesforce/src/salesforceBatchService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ export type SalesforceBatchStatus = 'Processing' | 'Aborted' | 'Queued' | 'Compl
export interface SalesforceBatchJob {
id: string;
createdById: string;
createdDate: string;
completedDate?: string;
createdDate: Date;
completedDate: Date | null;
apexClass: {
name: string;
namespacePrefix: string;
Expand All @@ -24,6 +24,10 @@ export interface SalesforceBatchJob {
}

export interface SalesforceBatchJobStatus {
/**
* ID of the batch job
*/
id: string;
/**
* Name of the APEX class executed by the batch
*/
Expand Down Expand Up @@ -193,22 +197,27 @@ export class SalesforceBatchService {
*/
public async getBatchStatus(filter: string | QueryFilterCondition) : Promise<SalesforceBatchJobStatus | undefined> {
const job = (await this.getBatchJobs(filter)).pop();
return (
job && {
elapsedTime: (job.completedDate ? DateTime.fromISO(job.completedDate) : DateTime.now()).diff(DateTime.fromISO(job.createdDate)).toMillis(),
apexClass: job.apexClass.name,
done: job.status === 'Completed' || job.status === 'Aborted',
status: job.status,
progress: job.jobItemsProcessed ?? 0,
total: job.totalJobItems ?? 0,
progressString: job.totalJobItems && job.jobItemsProcessed
? `${job.status} (${job.jobItemsProcessed}/${job.totalJobItems})`
: job?.status,
toString() {
return `${this.apexClass} (${this.id}) -- ${this.progressString} [${(this.elapsedTime / 1000).toFixed(1)}s]`;
}
} as any
);
if (!job) {
return;
}

const progressText = job.totalJobItems && job.jobItemsProcessed
? `${job.status} (${job.jobItemsProcessed}/${job.totalJobItems})`
: job?.status;

return {
id: job.id,
elapsedTime: (job.completedDate ? DateTime.fromJSDate(job.completedDate) : DateTime.now()).diff(DateTime.fromJSDate(job.createdDate)).toMillis(),
apexClass: job.apexClass.name,
done: job.status === 'Completed' || job.status === 'Aborted',
status: job.status,
progress: job.jobItemsProcessed ?? 0,
total: job.totalJobItems ?? 0,
// @ts-ignore ts(2322) -- allow toString to be added to the object
toString() {
return `${this.apexClass} (${this.id}) -- ${progressText} [${(this.elapsedTime / 1000).toFixed(1)}s]`;
}
};
}

/**
Expand Down
2 changes: 1 addition & 1 deletion packages/vlocity-deploy/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@
"@vlocode/util": "workspace:*",
"@vlocode/vlocity": "workspace:*",
"fs-extra": "^11",
"luxon": "^3.4.0",
"luxon": "^3.4.4",
"moment": "^2.29.4",
"sass": "^1.59.3"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/vscode-extension/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -1547,7 +1547,7 @@
"js-yaml": "^4.1.0",
"jsforce": "^1.11.0",
"log-symbols": "^4.0.0",
"luxon": "^3.4.0",
"luxon": "^3.4.4",
"open": "^8.2.1",
"reflect-metadata": "^0.1.13",
"shx": "^0.3.4",
Expand Down
Loading

0 comments on commit e331d01

Please sign in to comment.