Browse Source

add all errors to the progress

pull/6/head
rozetko 2 years ago
parent
commit
5c88c5adbe
  1. 66
      src/services/exporter.ts

66
src/services/exporter.ts

@ -28,39 +28,39 @@ export class Exporter {
private _task: ExportTask;
public async export(task: ExportTask, datasourceUrl: string) {
this._task = _.cloneDeep(task);
this._task.id = uuidv4();
this._task.progress = _.cloneDeep(DEFAULT_PROGRESS);
const targets = task.queries.map((query: DashboardQuery) => new Target(
query.panel,
query.datasource,
));
this._validateTargets(datasourceUrl, targets);
await this._updateProgress();
const queryConfigs = targets.map(
target =>
new QueryConfig(
QueryType.GRAFANA,
{
...target.datasource,
url: datasourceUrl
},
target.panel.targets
)
);
let from = +this._task.timeRange.from;
let to = +this._task.timeRange.to;
const days = Math.ceil((to - from) / MS_IN_DAY);
console.log(`Total days: ${days}`);
const stream = this._initCsvStream();
try {
this._task = _.cloneDeep(task);
this._task.id = uuidv4();
this._task.progress = _.cloneDeep(DEFAULT_PROGRESS);
const targets = task.queries.map((query: DashboardQuery) => new Target(
query.panel,
query.datasource,
));
this._validateTargets(datasourceUrl, targets);
await this._updateProgress();
const queryConfigs = targets.map(
target =>
new QueryConfig(
QueryType.GRAFANA,
{
...target.datasource,
url: datasourceUrl
},
target.panel.targets
)
);
let from = +this._task.timeRange.from;
let to = +this._task.timeRange.to;
const days = Math.ceil((to - from) / MS_IN_DAY);
console.log(`Total days: ${days}`);
const stream = this._initCsvStream();
for(let day = 0; day < days; day++) {
to = from + MS_IN_DAY;
@ -86,10 +86,10 @@ export class Exporter {
from += MS_IN_DAY;
}
stream.end();
} catch (e) {
await this._updateProgress({ status: ExportStatus.ERROR, errorMessage: e.message });
}
stream.end();
}
private _initCsvStream() {

Loading…
Cancel
Save