@@ -66,38 +66,37 @@ export const useSimulationQueries = (experiments: ExperimentResult[]): UseSimula
6666 combine : ( queryResults ) => {
6767 const data : Record < string , SimulationResults [ ] > = { } ;
6868
69- let simulationIndex : number = 0 ;
70-
71- for ( const result of queryResults ) {
69+ queryResults . forEach ( ( result , simulationIndex ) => {
70+ const simulation = simulationsToRun [ simulationIndex ] ;
7271 if ( result . isLoading ) {
73- ( data [ simulationsToRun [ simulationIndex ] . experiment . name ] ??= [ ] ) . push ( {
72+ ( data [ simulation . experiment . name ] ??= [ ] ) . push ( {
7473 status : "pending" ,
7574 finalConcentrations : { } ,
7675 modelInput : {
77- modelId : simulationsToRun [ simulationIndex ] . model . modelId ,
78- parameters : simulationsToRun [ simulationIndex ] . model . parameters
76+ modelId : simulation . model . modelId ,
77+ parameters : simulation . model . parameters
7978 ? Object . fromEntries (
80- Object . entries ( simulationsToRun [ simulationIndex ] . model . parameters ) . map (
81- ( [ key , value ] ) => [ key , value . default ]
82- )
79+ Object . entries ( simulation . model . parameters ) . map ( ( [ key , value ] ) => [
80+ key ,
81+ value . default ,
82+ ] )
8383 )
8484 : { } ,
8585 concentrations : Object . fromEntries (
86- Object . entries (
87- simulationsToRun [ simulationIndex ] . experiment . initialConcentrations
88- ) . filter ( ( [ , value ] ) => Number ( value ) !== 0 )
86+ Object . entries ( simulation . experiment . initialConcentrations ) . filter (
87+ ( [ , value ] ) => Number ( value ) !== 0
88+ )
8989 ) ,
9090 } ,
9191 panels : [ ] ,
9292 } ) ;
9393 }
9494
95- if ( ! result . data ) continue ;
96-
97- ( data [ result . data . experiment . name ] ??= [ ] ) . push ( result . data . result ) ;
95+ if ( result . data ) {
96+ ( data [ result . data . experiment . name ] ??= [ ] ) . push ( result . data . result ) ;
97+ }
98+ } ) ;
9899
99- simulationIndex += 1 ;
100- }
101100 const isLoading =
102101 queryResults . length !== simulationsToRun . length || queryResults . some ( ( value ) => value . isLoading ) ;
103102
0 commit comments