@@ -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 ,
@@ -4225,12 +4225,26 @@ const effects = {
42254225 const { plan_dataset : plan_datasets } = data ;
42264226 if ( plan_datasets != null ) {
42274227 let resources : Resource [ ] = [ ] ;
4228+
4229+ const profileMap : Set < string > = new Set ( ) ;
4230+ plan_datasets . sort ( ( { dataset_id : datasetIdA } , { dataset_id : datasetIdB } ) => {
4231+ return compare ( datasetIdA , datasetIdB , false ) ;
4232+ } ) ;
4233+
42284234 for ( const dataset of plan_datasets ) {
42294235 const {
42304236 dataset : { profiles } ,
42314237 offset_from_plan_start,
42324238 } = dataset ;
4233- const sampledResources : Resource [ ] = sampleProfiles ( profiles , startTimeYmd , offset_from_plan_start ) ;
4239+ const uniqueProfiles : Profile [ ] = profiles . filter ( profile => {
4240+ if ( ! profileMap . has ( profile . name ) ) {
4241+ profileMap . add ( profile . name ) ;
4242+ return true ;
4243+ }
4244+ return false ;
4245+ } ) ;
4246+
4247+ const sampledResources : Resource [ ] = sampleProfiles ( uniqueProfiles , startTimeYmd , offset_from_plan_start ) ;
42344248 resources = [ ...resources , ...sampledResources ] ;
42354249 }
42364250 return { aborted : false , resources } ;
0 commit comments