Skip to content

Commit

Permalink
🔧 Get total data, if no groups are specified.
Browse files Browse the repository at this point in the history
  • Loading branch information
JonasGilg committed Jan 20, 2025
1 parent a8bd086 commit 5ba0bd9
Showing 1 changed file with 18 additions and 8 deletions.
26 changes: 18 additions & 8 deletions frontend/src/DataContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ import {
useGetModelQuery,
useGetMultiParameterDefinitionsQuery,
useGetInterventionTemplatesQuery,
useGetNodeListsQuery, useGetNodesQuery,
useGetNodeListsQuery,
useGetNodesQuery,
} from 'store/services/scenarioApi';
import data from '../assets/lk_germany_reduced.geojson?url';
import {GeoJSON, GeoJsonProperties} from 'geojson';
Expand All @@ -31,7 +32,8 @@ import {
InterventionTemplates,
Model,
Models,
NodeLists, Nodes,
NodeLists,
Nodes,
ParameterDefinition,
Scenario,
ScenarioPreview,
Expand Down Expand Up @@ -121,6 +123,12 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
const {data: npis} = useGetInterventionTemplatesQuery();
const {data: nodeLists} = useGetNodeListsQuery();
const {data: nodes} = useGetNodesQuery();
const {data: groups} = useGetGroupsQuery();
const {data: groupCategories} = useGetGroupCategoriesQuery();

const totalGroup = useMemo(() => {
return groups?.find((group) => group.name === 'total');
}, [groups]);

useEffect(() => {
if (scenarios) {
Expand Down Expand Up @@ -170,10 +178,11 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
endDate: referenceDate!,
nodes: [selectedDistrict],
percentiles: ['50'],
groups: totalGroup ? [totalGroup.id] : [],
},
} as InfectionDataParameters,
{
skip: !caseDataScenario || !referenceDate,
skip: !caseDataScenario || !referenceDate || !totalGroup,
}
);

Expand All @@ -193,10 +202,11 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
endDate: selectedDate!,
nodes: [selectedDistrict],
percentiles: ['50'],
groups: totalGroup ? [totalGroup.id] : [],
},
},
{
skip: !caseDataScenario || !referenceDate,
skip: !caseDataScenario || !referenceDate || !totalGroup,
}
);

Expand Down Expand Up @@ -225,10 +235,11 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
query: {
nodes: [selectedDistrict],
compartments: [selectedCompartment!],
groups: totalGroup ? [totalGroup.id] : [],
},
},
{
skip: !selectedCompartment,
skip: !selectedCompartment || !totalGroup,
}
);

Expand All @@ -239,9 +250,10 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
startDate: selectedDate!,
endDate: selectedDate!,
compartments: [selectedCompartment!],
groups: totalGroup ? [totalGroup.id] : [],
},
},
{skip: !selectedScenario || !selectedDate || !selectedCompartment}
{skip: !selectedScenario || !selectedDate || !selectedCompartment || !totalGroup}
);

const {data: selectedScenarioData} = useGetScenarioQuery(selectedScenario!, {skip: !selectedScenario});
Expand All @@ -253,8 +265,6 @@ export const DataProvider = ({children}: {children: React.ReactNode}) => {
selectedSimulationModel?.parameterDefinitions ?? [],
{skip: !selectedSimulationModel}
);
const {data: groups} = useGetGroupsQuery();
const {data: groupCategories} = useGetGroupCategoriesQuery();

// Try to set at least one active scenario.
useEffect(() => {
Expand Down

0 comments on commit 5ba0bd9

Please sign in to comment.