From 1302800fc07846c512299191a8e3d33b9dd2b3a2 Mon Sep 17 00:00:00 2001 From: rozetko Date: Fri, 21 Sep 2018 19:19:25 +0300 Subject: [PATCH] Add current timestamp to filename --- src/target.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/target.ts b/src/target.ts index b8628c8..e797c33 100644 --- a/src/target.ts +++ b/src/target.ts @@ -16,6 +16,7 @@ export class Target { private day: number; private csvStream: any; private metric: Metric; + private createdTimestamp: number; constructor( private panelUrl: string, @@ -81,7 +82,7 @@ export class Target { } this.csvStream.end(); } - + // TODO: move csv-related stuff to service private initCsvStream() { this.csvStream = csv.createWriteStream({ headers: true }); let writableStream = fs.createWriteStream(this.getFilePath('csv')); @@ -107,7 +108,10 @@ export class Target { } 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) {