Skip to content

Commit

Permalink
[gh-#1192] track totalRunTime as part of the logs
Browse files Browse the repository at this point in the history
  • Loading branch information
khaliqgant committed Oct 30, 2023
1 parent e66057e commit 9617f8c
Showing 1 changed file with 15 additions and 3 deletions.
18 changes: 15 additions & 3 deletions packages/shared/lib/services/sync/run.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ export default class SyncRun {
// means a void response from the sync script which is expected
// and means that they're using batchSave or batchDelete
if (userDefinedResults === undefined) {
await this.finishSync(models, syncStartDate, syncData.version as string, trackDeletes);
await this.finishSync(models, syncStartDate, syncData.version as string, totalRunTime, trackDeletes);

return { success: true, error: null, response: true };
}
Expand Down Expand Up @@ -381,6 +381,7 @@ export default class SyncRun {
models.length,
syncStartDate,
syncData.version as string,
totalRunTime,
trackDeletes
);
}
Expand Down Expand Up @@ -414,7 +415,15 @@ export default class SyncRun {
if (upsertResult.success) {
const { summary } = upsertResult;

await this.reportResults(model, summary as UpsertSummary, i, models.length, syncStartDate, syncData.version as string);
await this.reportResults(
model,
summary as UpsertSummary,
i,
models.length,
syncStartDate,
syncData.version as string,
totalRunTime
);
}

if (!upsertResult.success) {
Expand Down Expand Up @@ -450,7 +459,7 @@ export default class SyncRun {
return { success: true, error: null, response: result };
}

async finishSync(models: string[], syncStartDate: Date, version: string, trackDeletes?: boolean): Promise<void> {
async finishSync(models: string[], syncStartDate: Date, version: string, totalRunTime: number, trackDeletes?: boolean): Promise<void> {
let i = 0;
for (const model of models) {
if (trackDeletes) {
Expand All @@ -469,6 +478,7 @@ export default class SyncRun {
models.length,
syncStartDate,
version,
totalRunTime,
trackDeletes
);
i++;
Expand All @@ -482,6 +492,7 @@ export default class SyncRun {
numberOfModels: number,
syncStartDate: Date,
version: string,
totalRunTime: number,
trackDeletes?: boolean
): Promise<void> {
if (!this.writeToDb || !this.activityLogId || !this.syncJobId) {
Expand Down Expand Up @@ -602,6 +613,7 @@ export default class SyncRun {
syncId: this.syncId as string,
syncJobId: String(this.syncJobId),
syncType: this.syncType,
totalRunTime: `${totalRunTime} seconds`,
debug: String(this.debug)
},
`syncId:${this.syncId}`
Expand Down

0 comments on commit 9617f8c

Please # to comment.