2021-11-12 11:47:19 +01:00
|
|
|
import {
|
|
|
|
IFeatureEnvironment,
|
|
|
|
IFeatureMetrics,
|
|
|
|
} from '../interfaces/featureToggle';
|
|
|
|
|
|
|
|
const emptyMetric = (environment: string) => ({
|
|
|
|
yes: 0,
|
|
|
|
no: 0,
|
|
|
|
environment,
|
|
|
|
timestamp: '',
|
|
|
|
});
|
|
|
|
|
|
|
|
export const getFeatureMetrics = (
|
|
|
|
environments: IFeatureEnvironment[],
|
2023-10-02 14:25:46 +02:00
|
|
|
metrics: IFeatureMetrics,
|
2021-11-12 11:47:19 +01:00
|
|
|
) => {
|
2023-10-02 14:25:46 +02:00
|
|
|
return environments.map((env) => {
|
2021-11-12 11:47:19 +01:00
|
|
|
const envMetric = metrics.lastHourUsage.find(
|
2023-10-02 14:25:46 +02:00
|
|
|
(metric) => metric.environment === env.name,
|
2021-11-12 11:47:19 +01:00
|
|
|
);
|
|
|
|
return envMetric || emptyMetric(env.name);
|
|
|
|
});
|
|
|
|
};
|