From 59aef00c2c87ddf5479325493c4c83cba551a502 Mon Sep 17 00:00:00 2001 From: Ludek Novy <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 8 Sep 2023 08:24:05 +0200 Subject: [PATCH 1/2] fix: upgrade pg from 8.11.2 to 8.11.3 (#258) Snyk has created this PR to upgrade pg from 8.11.2 to 8.11.3. See this package in npm: https://www.npmjs.com/package/pg See this project in Snyk: https://app.snyk.io/org/ludeknovy/project/6001874a-311f-46e3-8e8c-e69318c103b2?utm_source=github&utm_medium=referral&page=upgrade-pr Co-authored-by: snyk-bot --- package-lock.json | 8 ++++---- package.json | 2 +- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/package-lock.json b/package-lock.json index fe7269f9..bc35e3eb 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "moment": "^2.29.4", "multer": "^1.4.5-lts.1", "node-pg-migrate": "^6.2.2", - "pg": "^8.11.2", + "pg": "^8.11.3", "pg-promise": "^10.15.4", "swagger-ui-express": "^4.6.3", "uuid": "^9.0.0", @@ -9492,9 +9492,9 @@ } }, "node_modules/pg": { - "version": "8.11.2", - "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.2.tgz", - "integrity": "sha512-l4rmVeV8qTIrrPrIR3kZQqBgSN93331s9i6wiUiLOSk0Q7PmUxZD/m1rQI622l3NfqBby9Ar5PABfS/SulfieQ==", + "version": "8.11.3", + "resolved": "https://registry.npmjs.org/pg/-/pg-8.11.3.tgz", + "integrity": "sha512-+9iuvG8QfaaUrrph+kpF24cXkH1YOOUeArRNYIxq1viYHZagBxrTno7cecY1Fa44tJeZvaoG+Djpkc3JwehN5g==", "dependencies": { "buffer-writer": "2.0.0", "packet-reader": "1.0.0", diff --git a/package.json b/package.json index ff9c2ac6..1d45c826 100644 --- a/package.json +++ b/package.json @@ -37,7 +37,7 @@ "moment": "^2.29.4", "multer": "^1.4.5-lts.1", "node-pg-migrate": "^6.2.2", - "pg": "^8.11.2", + "pg": "^8.11.3", "pg-promise": "^10.15.4", "swagger-ui-express": "^4.6.3", "uuid": "^9.0.0", From 4f0853bab2925f9086e993742ef8193466b9140f Mon Sep 17 00:00:00 2001 From: Ludek Novy <13610612+ludeknovy@users.noreply.github.com> Date: Fri, 8 Sep 2023 11:23:32 +0200 Subject: [PATCH 2/2] fix: scenario trends label order (#259) --- .../trends/get-scenario-trends-controller.ts | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/src/server/controllers/scenario/trends/get-scenario-trends-controller.ts b/src/server/controllers/scenario/trends/get-scenario-trends-controller.ts index 683914e6..93f3c30e 100644 --- a/src/server/controllers/scenario/trends/get-scenario-trends-controller.ts +++ b/src/server/controllers/scenario/trends/get-scenario-trends-controller.ts @@ -18,13 +18,16 @@ export const getScenarioTrendsController = async (req: IGetUserAuthInfoRequest, const responseTimeDegradationCurve = await db.manyOrNone( searchResponseTimeDegradation(projectName, scenarioName, envChecked)) - const labelTrends = labelData.map(data => data.stats.map(value => ({ - percentile90: [data.startDate, value.n0, data.id], - errorRate: [data.startDate, value.errorRate, data.id], - throughput: [data.startDate, value.throughput, data.id], - label: value.label, - }))) + labelData.sort(sortByDateAsc) + const labelTrends = labelData.map(data => data.stats.map(value => { + return { + percentile90: [data.startDate, value.n0, data.id], + errorRate: [data.startDate, value.errorRate, data.id], + throughput: [data.startDate, value.throughput, data.id], + label: value.label, + } + })) const adjusted = {} @@ -39,6 +42,7 @@ export const getScenarioTrendsController = async (req: IGetUserAuthInfoRequest, }) }) + const networkAdjustedData = aggregatedData.map((_) => { const { bytesPerSecond, bytesSentPerSecond } = _.overview const network = bytesPerSecond + bytesSentPerSecond @@ -66,7 +70,7 @@ export const getScenarioTrendsController = async (req: IGetUserAuthInfoRequest, }) res.status(StatusCode.Ok).json({ - aggregatedTrends: networkAdjustedData.sort(sortByDateAsc), + aggregatedTrends: networkAdjustedData.sort(sortAggDataByDateAsc), responseTimeDegradationCurve: responseTimeDegradationCurveSeries, labelTrends: adjusted, userSettings: { @@ -80,7 +84,12 @@ export const getScenarioTrendsController = async (req: IGetUserAuthInfoRequest, }) } -const sortByDateAsc = (a, b): number => { +const sortAggDataByDateAsc = (a, b): number => { return new Date(a.overview.startDate).getTime() - new Date(b.overview.startDate).getTime() } +const sortByDateAsc = (a, b): number => { + return new Date(a.startDate).getTime() - new Date(b.startDate).getTime() + +} +