1
0
mirror of https://github.com/Unleash/unleash.git synced 2025-01-11 00:08:30 +01:00

fix: metrics performance patch (#4108)

This commit is contained in:
Jaanus Sellin 2023-06-29 13:14:37 +03:00 committed by GitHub
parent 65995b238a
commit 19770fc33c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -162,15 +162,19 @@ export default class ClientMetricsServiceV2 {
100,
);
const result = environments.flatMap((environment) =>
applications.flatMap((appName) =>
hours.flatMap((hourBucket) => {
const metric = metrics.find(
const result = environments.flatMap((environment) => {
const environmentMetrics = metrics.filter(
(metric) => metric.environment === environment,
);
return applications.flatMap((appName) => {
const applicationMetrics = environmentMetrics.filter(
(metric) => metric.appName === appName,
);
return hours.flatMap((hourBucket) => {
const metric = applicationMetrics.find(
(item) =>
compareAsc(hourBucket.timestamp, item.timestamp) ===
0 &&
item.appName === appName &&
item.environment === environment,
0,
);
return (
metric || {
@ -182,10 +186,9 @@ export default class ClientMetricsServiceV2 {
featureName,
}
);
}),
),
);
});
});
});
return result.sort((a, b) => compareAsc(a.timestamp, b.timestamp));
}