Skip to content

Commit

Permalink
fix: scenario trends label order (#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
ludeknovy authored Sep 8, 2023
1 parent 59aef00 commit 4f0853b
Showing 1 changed file with 17 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {}

Expand All @@ -39,6 +42,7 @@ export const getScenarioTrendsController = async (req: IGetUserAuthInfoRequest,
})
})


const networkAdjustedData = aggregatedData.map((_) => {
const { bytesPerSecond, bytesSentPerSecond } = _.overview
const network = bytesPerSecond + bytesSentPerSecond
Expand Down Expand Up @@ -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: {
Expand All @@ -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()

}

0 comments on commit 4f0853b

Please sign in to comment.