Browse Source

Change exported filenames #8

pull/1/head
rozetko 6 years ago
parent
commit
d9f6adc6e4
  1. 10
      src/target.ts

10
src/target.ts

@ -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) {

Loading…
Cancel
Save