Skip to content

Commit

Permalink
update metricsTypes
Browse files Browse the repository at this point in the history
Using the '/metrics/yyyy_mm_dd' endpoint on the server, there is no longer a discrepancy between server metric data and client metric data.
Also, we can support a variety of GroupingFields now, instead of just 'mode', and the metric values can be objects instead of just numbers.
  • Loading branch information
JGreenlee committed May 24, 2024
1 parent 637d496 commit 66bbc62
Showing 1 changed file with 11 additions and 14 deletions.
25 changes: 11 additions & 14 deletions www/js/metrics/metricsTypes.ts
Original file line number Diff line number Diff line change
@@ -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_<mode>, where <mode> 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_<mode>, where <mode> 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[];
};

0 comments on commit 66bbc62

Please sign in to comment.