mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-28 14:06:00 +00:00
report read row count, if written row count not available
This commit is contained in:
@@ -1,8 +1,25 @@
|
||||
const EnsureStreamHeaderStream = require('../utility/EnsureStreamHeaderStream');
|
||||
const ColumnMapTransformStream = require('../utility/ColumnMapTransformStream');
|
||||
const streamPipeline = require('../utility/streamPipeline');
|
||||
const { getLogger, extractErrorLogData } = require('dbgate-tools');
|
||||
const { getLogger, extractErrorLogData, RowProgressReporter } = require('dbgate-tools');
|
||||
const logger = getLogger('copyStream');
|
||||
const stream = require('stream');
|
||||
|
||||
class ReportingTransform extends stream.Transform {
|
||||
constructor(reporter, options = {}) {
|
||||
super({ ...options, objectMode: true });
|
||||
this.reporter = reporter;
|
||||
}
|
||||
_transform(chunk, encoding, callback) {
|
||||
this.reporter.add(1);
|
||||
this.push(chunk);
|
||||
callback();
|
||||
}
|
||||
_flush(callback) {
|
||||
this.reporter.finish();
|
||||
callback();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Copies reader to writer. Used for import, export tables and transfer data between tables
|
||||
@@ -23,6 +40,11 @@ async function copyStream(input, output, options) {
|
||||
}
|
||||
|
||||
const transforms = [];
|
||||
|
||||
if (progressName) {
|
||||
const reporter = new RowProgressReporter(progressName, 'readRowCount');
|
||||
transforms.push(new ReportingTransform(reporter));
|
||||
}
|
||||
if (columns) {
|
||||
transforms.push(new ColumnMapTransformStream(columns));
|
||||
}
|
||||
|
||||
@@ -25,3 +25,4 @@ export * from './detectSqlFilterBehaviour';
|
||||
export * from './filterBehaviours';
|
||||
export * from './schemaInfoTools';
|
||||
export * from './dbKeysLoader';
|
||||
export * from './rowProgressReporter';
|
||||
@@ -307,7 +307,9 @@
|
||||
{#if progressHolder[row]?.status == 'running'}
|
||||
<FontIcon icon="icon loading" />
|
||||
{#if progressHolder[row]?.writtenRowCount}
|
||||
{progressHolder[row]?.writtenRowCount} rows written
|
||||
{progressHolder[row]?.writtenRowCount} rows writtem
|
||||
{:else if progressHolder[row]?.readRowCount}
|
||||
{progressHolder[row]?.readRowCount} rows read
|
||||
{:else}
|
||||
Running
|
||||
{/if}
|
||||
@@ -325,6 +327,8 @@
|
||||
<FontIcon icon="img ok" />
|
||||
{#if progressHolder[row]?.writtenRowCount}
|
||||
{progressHolder[row]?.writtenRowCount} rows written
|
||||
{:else if progressHolder[row]?.readRowCount}
|
||||
{progressHolder[row]?.readRowCount} rows read
|
||||
{:else}
|
||||
Done
|
||||
{/if}
|
||||
|
||||
Reference in New Issue
Block a user