Browse Source

Add current timestamp to filename

pull/1/head
rozetko 6 years ago
parent
commit
1302800fc0
  1. 8
      src/target.ts

8
src/target.ts

@ -16,6 +16,7 @@ export class Target {
private day: number; private day: number;
private csvStream: any; private csvStream: any;
private metric: Metric; private metric: Metric;
private createdTimestamp: number;
constructor( constructor(
private panelUrl: string, private panelUrl: string,
@ -81,7 +82,7 @@ export class Target {
} }
this.csvStream.end(); this.csvStream.end();
} }
// TODO: move csv-related stuff to service
private initCsvStream() { private initCsvStream() {
this.csvStream = csv.createWriteStream({ headers: true }); this.csvStream = csv.createWriteStream({ headers: true });
let writableStream = fs.createWriteStream(this.getFilePath('csv')); let writableStream = fs.createWriteStream(this.getFilePath('csv'));
@ -107,7 +108,10 @@ export class Target {
} }
private getFilename(extension) { private getFilename(extension) {
return `${this.datasourceName}.${this.from}-${this.to}.${extension}`; if(this.createdTimestamp === undefined) {
this.createdTimestamp = moment().valueOf();
}
return `${this.createdTimestamp}.${this.datasourceName}.${extension}`;
} }
private getFilePath(extension) { private getFilePath(extension) {

Loading…
Cancel
Save