@@ -213,7 +213,7 @@ import type {
213213import type { Row , Timeline } from '../types/timeline' ;
214214import type { View , ViewDefinition , ViewInsertInput , ViewSlim , ViewUpdateInput } from '../types/view' ;
215215import { ActivityDeletionAction } from './activities' ;
216- import { convertToQuery , getSearchParameterNumber , setQueryParam } from './generic' ;
216+ import { compare , convertToQuery , getSearchParameterNumber , setQueryParam } from './generic' ;
217217import gql , { convertToGQLArray } from './gql' ;
218218import {
219219 showConfirmModal ,
@@ -4230,12 +4230,26 @@ const effects = {
42304230 const { plan_dataset : plan_datasets } = data ;
42314231 if ( plan_datasets != null ) {
42324232 let resources : Resource [ ] = [ ] ;
4233+
4234+ const profileMap : Set < string > = new Set ( ) ;
4235+ plan_datasets . sort ( ( { dataset_id : datasetIdA } , { dataset_id : datasetIdB } ) => {
4236+ return compare ( datasetIdA , datasetIdB , false ) ;
4237+ } ) ;
4238+
42334239 for ( const dataset of plan_datasets ) {
42344240 const {
42354241 dataset : { profiles } ,
42364242 offset_from_plan_start,
42374243 } = dataset ;
4238- const sampledResources : Resource [ ] = sampleProfiles ( profiles , startTimeYmd , offset_from_plan_start ) ;
4244+ const uniqueProfiles : Profile [ ] = profiles . filter ( profile => {
4245+ if ( ! profileMap . has ( profile . name ) ) {
4246+ profileMap . add ( profile . name ) ;
4247+ return true ;
4248+ }
4249+ return false ;
4250+ } ) ;
4251+
4252+ const sampledResources : Resource [ ] = sampleProfiles ( uniqueProfiles , startTimeYmd , offset_from_plan_start ) ;
42394253 resources = [ ...resources , ...sampledResources ] ;
42404254 }
42414255 return { aborted : false , resources } ;
0 commit comments