diff --git a/src/database/clickhouse/clickhouse.service.ts b/src/database/clickhouse/clickhouse.service.ts index 9418256..9e493ee 100644 --- a/src/database/clickhouse/clickhouse.service.ts +++ b/src/database/clickhouse/clickhouse.service.ts @@ -132,12 +132,13 @@ export class ClickhouseService { // for (let query of insertQuery) { try{ let retRaw = await connectionData.query(insertRawQuery).toPromise(); + console.log(retRaw); } catch{ console.log(insertRawQuery); } - // console.log(retRaw); - // } + // console.log(retRaw); + // } break; case 'complex': let insertComplexQuery = 'INSERT INTO complex_parameters VALUES(toDateTime(now()), \'{{parameterBody}}\', toDateTime(now()));'; diff --git a/src/zvksmetrics/zvksmetrics.controller.ts b/src/zvksmetrics/zvksmetrics.controller.ts index 34a5d1c..8620412 100644 --- a/src/zvksmetrics/zvksmetrics.controller.ts +++ b/src/zvksmetrics/zvksmetrics.controller.ts @@ -66,6 +66,15 @@ export class ZvksmetricsController { return ret; } + @Post('formulas/:code') + async setFormulas(@Body() inputFormulas: any, @Param('code', ParseIntPipe) code: number): Promise { + let ret: string = "Controller Error"; + if (code === 1111) { + return await this.metricsService.saveFormulas(inputFormulas); + } + return ret; + } + @Post('input') async getPostMessage(@Body() inputMetrics: any): Promise { // console.log(inputMetrics); diff --git a/src/zvksmetrics/zvksmetrics.service.ts b/src/zvksmetrics/zvksmetrics.service.ts index 106fbd0..6588b8b 100644 --- a/src/zvksmetrics/zvksmetrics.service.ts +++ b/src/zvksmetrics/zvksmetrics.service.ts @@ -379,6 +379,22 @@ export class ZvksmetricsService { return ret; } + async saveFormulas(inputFormulas: string): Promise { + let ret: any; + let filePath: any = process.env.FORMULAS_CONFIG; + // console.log(inputRanges); + let inp: string = JSON.stringify(inputFormulas); + try { + await writeFile(filePath, inp); + ret = "200 OK"; + } + catch { + ret = "Error write file"; + console.log(ret); + } + return ret; + } + async setComplexMetrics(@Body() complexData: any = null): Promise { let url: any = process.env.COMPLEX_METRICS; let options: any = {