Skip to content

Commit

Permalink
refactor(frontend): remove dummy time intervals and thresholds
Browse files Browse the repository at this point in the history
- Remove dummy data for secondary parameters.
- Update `useParameters` for the case where we haven't defined any intervals yet.
  • Loading branch information
eatyourgreens committed Nov 21, 2024
1 parent 804c15e commit a41b82d
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 57 deletions.
27 changes: 2 additions & 25 deletions frontend-v2/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -25,32 +25,9 @@ export type TimeInterval = {
type Threshold = { lower: number; upper: number };
export type Thresholds = { [key: string]: Threshold };

const TIME_INTERVALS: TimeInterval[] = [
{ start: 0, end: 168, unit: "h" },
{ start: 168, end: 336, unit: "h" },
{ start: 336, end: 504, unit: "h" },
{ start: 504, end: 672, unit: "h" },
{ start: 672, end: 840, unit: "h" },
];
const TIME_INTERVALS: TimeInterval[] = [];

const THRESHOLDS: Thresholds = {
C1: {
lower: 1e4,
upper: Infinity,
},
C1_t: {
lower: 5e4,
upper: Infinity,
},
CT1_f: {
lower: 200,
upper: Infinity,
},
CT1_b: {
lower: 900,
upper: Infinity,
},
};
const THRESHOLDS: Thresholds = {};

function App() {
const dispatch = useAppDispatch();
Expand Down
74 changes: 42 additions & 32 deletions frontend-v2/src/features/results/useParameters.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,9 @@ export function useParameters() {
simulation,
intervalIndex,
);
return formattedNumber(Math.min(...intervalValues));
return intervalValues
? formattedNumber(Math.min(...intervalValues))
: 0;
},
},
{
Expand All @@ -99,7 +101,9 @@ export function useParameters() {
simulation,
intervalIndex,
);
return formattedNumber(Math.max(...intervalValues));
return intervalValues
? formattedNumber(Math.max(...intervalValues))
: 0;
},
},
{
Expand Down Expand Up @@ -140,14 +144,16 @@ export function useParameters() {
simulation,
intervalIndex,
);
return formattedNumber(
timeOverLowerThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
);
return intervalValues
? formattedNumber(
timeOverLowerThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
)
: 0;
},
},
{
Expand All @@ -167,14 +173,16 @@ export function useParameters() {
simulation,
intervalIndex,
);
return formattedNumber(
timeOverUpperThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
);
return intervalValues
? formattedNumber(
timeOverUpperThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
)
: 0;
},
},
{
Expand All @@ -194,20 +202,22 @@ export function useParameters() {
simulation,
intervalIndex,
);
return formattedNumber(
timeOverLowerThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
) -
timeOverUpperThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
);
return intervalValues
? formattedNumber(
timeOverLowerThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
) -
timeOverUpperThresholdPerInterval(
intervalValues,
intervalTimes,
variable,
thresholds,
),
)
: 0;
},
},
] as Parameter[];
Expand Down

0 comments on commit a41b82d

Please sign in to comment.