import type { AdminMetric } from '../types/awards'

export function getMetricValue(metrics: AdminMetric[], labels: string[]) {
  const normalizedLabels = labels.map((label) => label.toLowerCase())
  return metrics.find((metric) => normalizedLabels.includes(metric.label.toLowerCase()))?.value ?? 0
}

export function getVoteMetricValue(metrics: AdminMetric[]) {
  return getMetricValue(metrics, ['Stimmen', 'Votes'])
}

export function getRiskMetricValue(metrics: AdminMetric[]) {
  return getMetricValue(metrics, ['Risikohinweise', 'Risk Flags', 'Risiko'])
}
