mirror of
https://github.com/Unleash/unleash.git
synced 2025-10-13 11:17:26 +02:00
We're migrating to ESM, which will allow us to import the latest versions of our dependencies. Co-Authored-By: Christopher Kolstad <chriswk@getunleash.io>
23 lines
538 B
TypeScript
23 lines
538 B
TypeScript
import type {
|
|
IFeatureEnvironment,
|
|
IFeatureMetrics,
|
|
} from '../interfaces/featureToggle.js';
|
|
|
|
const emptyMetric = (environment: string) => ({
|
|
yes: 0,
|
|
no: 0,
|
|
environment,
|
|
timestamp: '',
|
|
});
|
|
|
|
export const getFeatureMetrics = (
|
|
environments: IFeatureEnvironment[],
|
|
metrics: IFeatureMetrics,
|
|
) =>
|
|
environments.map((env) => {
|
|
const envMetric = metrics.lastHourUsage.find(
|
|
(metric) => metric.environment === env.name,
|
|
);
|
|
return envMetric || emptyMetric(env.name);
|
|
});
|