|
|
@ -23,7 +23,8 @@ export class Target { |
|
|
|
datasource: Datasource, |
|
|
|
datasource: Datasource, |
|
|
|
targets: Array<Object>, |
|
|
|
targets: Array<Object>, |
|
|
|
private from: number, |
|
|
|
private from: number, |
|
|
|
private to: number |
|
|
|
private to: number, |
|
|
|
|
|
|
|
private datasourceName: string, |
|
|
|
) { |
|
|
|
) { |
|
|
|
this.metric = new Metric(datasource, targets); |
|
|
|
this.metric = new Metric(datasource, targets); |
|
|
|
} |
|
|
|
} |
|
|
@ -35,7 +36,8 @@ export class Target { |
|
|
|
user: this.user, |
|
|
|
user: this.user, |
|
|
|
exportedRows: this.exportedRows, |
|
|
|
exportedRows: this.exportedRows, |
|
|
|
progress: (this.day / this.days).toLocaleString('en', { style: 'percent' }), |
|
|
|
progress: (this.day / this.days).toLocaleString('en', { style: 'percent' }), |
|
|
|
status |
|
|
|
status, |
|
|
|
|
|
|
|
datasourceName: this.datasourceName |
|
|
|
}; |
|
|
|
}; |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
return new Promise((resolve, reject) => { |
|
|
|
fs.writeFile(this.getFilePath('json'), JSON.stringify(data), 'utf8', err => { |
|
|
|
fs.writeFile(this.getFilePath('json'), JSON.stringify(data), 'utf8', err => { |
|
|
@ -105,9 +107,7 @@ export class Target { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getFilename(extension) { |
|
|
|
private getFilename(extension) { |
|
|
|
// TODO: use something unique instead of measurement in filename
|
|
|
|
return `${this.datasourceName}.${this.from}-${this.to}.${extension}`; |
|
|
|
// as measurement field exists only in influxDB metric
|
|
|
|
|
|
|
|
return `${this.metric.targets[0].measurement}.${this.from}-${this.to}.${extension}`; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private getFilePath(extension) { |
|
|
|
private getFilePath(extension) { |
|
|
|