Skip to content

Commit 57b4362

Browse files
committed
better progression
1 parent 4f133ee commit 57b4362

File tree

2 files changed

+5
-7
lines changed

2 files changed

+5
-7
lines changed

src/generation/filler.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,7 @@ export class Filler {
126126
try {
127127
row[column.name] = generators[c].generate(currentTableRow, row);
128128
} catch (ex) {
129-
this.callback({ currentTable: table.name, step: 'generateData', state: 'RUNNING', currentValue: currentNbRows, max: maxLines, comment: (ex as Error).message });
129+
this.callback({ currentTable: table.name, step: 'generateData', state: 'RUNNING', currentValue: currentNbRows, max: maxLines, comment: (ex as Error).message + '. ' });
130130
break BATCH_LOOP;
131131
}
132132

@@ -138,7 +138,7 @@ export class Filler {
138138
insertedRows = await this.dbConnector.insert(table.name, rows);
139139
currentNbRows += insertedRows;
140140
if (previousRunRows === currentNbRows) {
141-
this.callback({ currentTable: table.name, step: 'generateData', state: 'DONE', currentValue: currentNbRows, max: maxLines, comment: 'Last run did not insert any rows' });
141+
this.callback({ currentTable: table.name, step: 'generateData', state: 'DONE', currentValue: currentNbRows, max: maxLines, comment: 'Last run did not insert any rows. ' });
142142
break TABLE_LOOP;
143143
}
144144
this.callback({ currentTable: table.name, step: 'generateData', state: 'RUNNING', currentValue: currentNbRows, max: maxLines });

src/main.ts

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -126,7 +126,6 @@ class Main extends CliMainClass {
126126
progressEventHandler() {
127127
let previousEvent: ProgressEvent = { currentTable: '', currentValue: 0, max: 0, state: 'DONE', step: '' };
128128
let currentProgress: SingleBar;
129-
let lastComment: string = '';
130129
return (event: ProgressEvent) => {
131130
let diff = false;
132131
if (previousEvent.currentTable !== event.currentTable) {
@@ -137,16 +136,15 @@ class Main extends CliMainClass {
137136
diff = true;
138137
}
139138
if (diff === true) {
140-
lastComment = '';
141139
if (currentProgress) currentProgress.stop();
142140
currentProgress = new cliProgress.SingleBar({
143141
format: `${event.step + new Array(16 - event.step.length).join(' ')} | ${colors.cyan('{bar}')} | {percentage}% | {value}/{total} | {comment}`,
144142
stopOnComplete: true,
145143
});
146-
currentProgress.start(event.max, event.currentValue, { comment: event.comment || lastComment });
144+
currentProgress.start(event.max, event.currentValue, { comment: event.comment || '' });
147145
} else {
148-
if (currentProgress) currentProgress.update(event.currentValue, { comment: event.comment || lastComment });
149-
if (event.comment) lastComment = event.comment;
146+
event.comment = [previousEvent.comment, event.comment].join('');
147+
if (currentProgress) currentProgress.update(event.currentValue, { comment: event.comment });
150148
if (event.state === 'DONE') currentProgress.stop();
151149
}
152150
previousEvent = event;

0 commit comments

Comments
 (0)