From bc99177b5b084cd3cbe89bfd619b6c28ffdae73a Mon Sep 17 00:00:00 2001 From: Russel Cole Date: Mon, 25 Nov 2024 08:58:01 +0000 Subject: [PATCH] PRESIDECMS-2941 get savedFiltersList once --- .../PresideObjectSavedFilterService.cfc | 2 ++ .../presideObjects/PresideObjectService.cfc | 29 ++++++++++++------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/system/services/presideObjects/PresideObjectSavedFilterService.cfc b/system/services/presideObjects/PresideObjectSavedFilterService.cfc index 4766f237a8..eeef2c085f 100644 --- a/system/services/presideObjects/PresideObjectSavedFilterService.cfc +++ b/system/services/presideObjects/PresideObjectSavedFilterService.cfc @@ -39,6 +39,8 @@ component { return { filter = filter.filter ?: {} , filterParams = filter.filterParams ?: {} + , having = filter.having ?: "" + , extraJoins = filter.extraJoins ?: [] }; } diff --git a/system/services/presideObjects/PresideObjectService.cfc b/system/services/presideObjects/PresideObjectService.cfc index 935e6791e9..8130056ce3 100644 --- a/system/services/presideObjects/PresideObjectService.cfc +++ b/system/services/presideObjects/PresideObjectService.cfc @@ -228,6 +228,14 @@ component displayName="Preside Object Service" { } } + args.savedFilterList = []; + + var filterService = _getFilterService(); + + for( var savedFilter in arguments.savedFilters ){ + ArrayAppend( args.savedFilterList, filterService.getFilter( savedFilter ) ); + } + args.extraFilters.append( _expandSavedFilters( argumentCollection=args ), true ); if ( args.useCache ) { @@ -3384,10 +3392,10 @@ component displayName="Preside Object Service" { private array function _convertObjectJoinsToTableJoins( required array joins - , array extraJoins = [] - , array extraFilters = [] - , array savedFilters = [] - , struct preparedFilter = {} + , array extraJoins = [] + , array extraFilters = [] + , array savedFilterList = [] + , struct preparedFilter = {} ) { var tableJoins = []; var objJoin = ""; @@ -3430,8 +3438,9 @@ component displayName="Preside Object Service" { tableJoins.append( arguments.extraJoins, true ); - for( var savedFilter in arguments.savedFilters ){ - savedFilter = _getFilterService().getFilter( savedFilter ); + for( var savedFilter in arguments.savedFilterList ){ + + arguments.preparedFilter.params = arguments.preparedFilter.params ?: []; if ( IsArray( savedFilter.extraJoins ?: "" ) ) { tableJoins.append( savedFilter.extraJoins, true ); @@ -3832,13 +3841,11 @@ component displayName="Preside Object Service" { return _relationshipPathCalcCache[ cacheKey ]; } - private array function _expandSavedFilters( required array savedFilters ) { + private array function _expandSavedFilters( required array savedFilterList ) { var expanded = []; - var filterService = _getFilterService(); - - for( var savedFilter in arguments.savedFilters ){ - savedFilter = filterService.getFilter( savedFilter ); + /*var filterService = _getFilterService();*/ + for( var savedFilter in arguments.savedFilterList ){ expanded.append({ filter = savedFilter.filter ?: {} , filterParams = savedFilter.filterParams ?: {}