20 lines
475 B
TypeScript
20 lines
475 B
TypeScript
import type { PerformanceCriteria } from "@/types";
|
|
import groupBy from "lodash/groupBy";
|
|
|
|
export function calcPerformanceCriteriaStatusCount(criteria: PerformanceCriteria[]) {
|
|
if (criteria) {
|
|
const grouped = groupBy(criteria, "completion_status");
|
|
return {
|
|
UNKNOWN: grouped?.UNKNOWN?.length || 0,
|
|
SUCCESS: grouped?.SUCCESS?.length || 0,
|
|
FAIL: grouped?.FAIL?.length || 0,
|
|
};
|
|
}
|
|
|
|
return {
|
|
UNKNOWN: 0,
|
|
SUCCESS: 0,
|
|
FAIL: 0,
|
|
};
|
|
}
|