diff --git a/www/js/metrics/metricsTypes.ts b/www/js/metrics/metricsTypes.ts index eb70e7b22..e2fc4d5df 100644 --- a/www/js/metrics/metricsTypes.ts +++ b/www/js/metrics/metricsTypes.ts @@ -1,21 +1,18 @@ -import { LocalDt } from '../types/serverData'; -import { MetricName } from '../types/appConfigTypes'; +import { GroupingField, MetricName } from '../types/appConfigTypes'; -type LabelProps = { [k in `label_${string}`]?: number }; // label_, where could be anything -export type DayOfServerMetricData = LabelProps & { - ts: number; - fmt_time: string; - nUsers: number; - local_dt: LocalDt; -}; - -type ModeProps = { [k in `mode_${string}`]?: number }; // mode_, where could be anything -export type DayOfClientMetricData = ModeProps & { +// distance, duration, and count use number values in meters, seconds, and count respectively +// response_count uses object values containing responded and not_responded counts +type MetricValue = number | { responded?: number; not_responded?: number }; +export type DayOfMetricData = { date: string; // yyyy-mm-dd + nUsers: number; +} & { + // each key is a value for a specific grouping field + // and the value is the respective metric value + // e.g. { mode_confirm_bikeshare: 123, survey_TripConfirmSurvey: { responded: 4, not_responded: 5 } + [k in `${GroupingField}_${string}`]: MetricValue; }; -export type DayOfMetricData = DayOfClientMetricData | DayOfServerMetricData; - export type MetricsData = { [key in MetricName]: DayOfMetricData[]; };