diff --git a/src/routes/tasks.ts b/src/routes/tasks.ts index 9c5f646..37ba9ca 100644 --- a/src/routes/tasks.ts +++ b/src/routes/tasks.ts @@ -75,7 +75,6 @@ async function addTask(req: TRequest, res) { res.status(400).send('Range error: "from" should be less than "to"'); } else { const names = tasks.map(item => item.datasource.name).join(', '); - res.status(200).send(`Exporting ${names} data from ${new Date(from).toLocaleString()} to ${new Date(to).toLocaleString()}`); const targets = tasks.map((task: Task) => new Target( task.panel, @@ -83,6 +82,7 @@ async function addTask(req: TRequest, res) { )); const exporter = exporterFactory.getExporter(); exporter.export(targets, datasourceUrl, username, from, to); + res.status(200).send(`Exporting ${names} data from ${new Date(from).toLocaleString()} to ${new Date(to).toLocaleString()}`); } } diff --git a/src/services/exporter.ts b/src/services/exporter.ts index e7899b2..1bda0d6 100644 --- a/src/services/exporter.ts +++ b/src/services/exporter.ts @@ -84,6 +84,8 @@ export class Exporter { this.datasourceRef = data.length === 1 ? data[0].datasource : { uid: 'all', type: 'all' }; + await this.updateStatus(ExportStatus.EXPORTING, 0); + const stream = this.initCsvStream(); const days = Math.ceil((to - from) / MS_IN_DAY);