Skip to content
Permalink
Browse files

Merge branch 'hotfix-10.10.60' into stable

  • Loading branch information...
sebduggan committed Apr 8, 2019
2 parents 4098ee2 + b1af218 commit 5597d8432d4e610f140ef4c9798f80ed345c3ba4
@@ -629,16 +629,46 @@ component extends="resources.HelperObjects.PresideBddTestCase" {
} );

describe( "getUserLastPerformedActionFilter()", function(){
it( "should return an empty array when both dateFrom and dateTo are empty", function(){
var service = _getService();
var filter = service.getUserLastPerformedActionFilter(
action = "blah"
, type = "blah"
, dateFrom = ""
, dateTo = ""
it( "should return filter with no date criteria when both dateFrom and dateTo are empty", function(){
var service = _getService();
var testAction = CreateUUId();
var testType = CreateUUId();
var dummySubquerySql = CreateUUId();
var from = "";
var to = "";
var expected = [{}];

expected[ 1 ].filter = "";
expected[ 1 ].filterParams = {
"action#testFilterSuffix#" = { type="cf_sql_varchar" , value=testAction }
, "type#testFilterSuffix#" = { type="cf_sql_varchar" , value=testType }
};
expected[ 1 ].extraJoins = [ {
type = "inner"
, subQuery = dummySubquerySql
, subQueryAlias = "lastPerformed" & testFilterSuffix
, subQueryColumn = "id"
, joinToTable = "website_user"
, joinToColumn = "id"
} ];

mockUserDao.$( "selectData" ).$args(
selectFields = [ "Max( actions.datecreated ) as action_date", "website_user.id" ]
, filter = "actions.action = :action#testFilterSuffix# and actions.type = :type#testFilterSuffix#"
, groupby = "website_user.id"
, getSqlAndParamsOnly = true
, forceJoins = "inner"
).$results( { sql=dummySubquerySql, params={} } );


var filter = service.getUserLastPerformedActionFilter(
action = testAction
, type = testType
, dateFrom = from
, dateTo = to
);

expect( filter ).toBe( [] );
expect( filter ).toBe( expected );
} );

it( "should return filter for date matching the last performed date of the given action / type", function(){
@@ -658,7 +688,7 @@ component extends="resources.HelperObjects.PresideBddTestCase" {
, "dateto#testFilterSuffix#" = { type="cf_sql_timestamp", value=to }
};
expected[ 1 ].extraJoins = [ {
type = "left"
type = "inner"
, subQuery = dummySubquerySql
, subQueryAlias = "lastPerformed" & testFilterSuffix
, subQueryColumn = "id"
@@ -704,7 +734,7 @@ component extends="resources.HelperObjects.PresideBddTestCase" {
, "identifier#testFilterSuffix#" = { type="cf_sql_varchar" , value=identifier }
};
expected[ 1 ].extraJoins = [ {
type = "left"
type = "inner"
, subQuery = dummySubquerySql
, subQueryAlias = "lastPerformed" & testFilterSuffix
, subQueryColumn = "id"
@@ -40,16 +40,19 @@ component {
*/
private array function prepareFilters(
required string action
, boolean _has = true
, struct _pastTime
, string filterPrefix
, string parentPropertyName
, boolean _has = true
, struct _pastTime = {}
, string filterPrefix = ""
, string parentPropertyName = ""
) {
return websiteUserActionService.getUserLastPerformedActionFilter(
type = ListFirst( arguments.action, "." )
, action = ListRest( arguments.action, "." )
return websiteUserActionService.getUserPerformedActionFilter(
action = ListRest( arguments.action, "." )
, type = ListFirst( arguments.action, "." )
, has = arguments._has
, datefrom = arguments._pastTime.from ?: ""
, dateto = arguments._pastTime.to ?: ""
, qty = 0
, qtyOperator = arguments._has ? "gt" : "eq"
, filterPrefix = arguments.filterPrefix
, parentPropertyName = arguments.parentPropertyName
);
@@ -333,10 +333,6 @@ component displayName="Website user action service" {
, string filterPrefix = ""
, string parentPropertyName = ""
) {
if ( !IsDate( arguments.dateFrom ) && !IsDate( arguments.dateTo ) ) {
return [];
}

var paramSuffix = _getRandomFilterParamSuffix();
var subqueryFilter = "actions.action = :action#paramSuffix# and actions.type = :type#paramSuffix#";
var subqueryAlias = "lastPerformed" & paramSuffix;
@@ -370,7 +366,7 @@ component displayName="Website user action service" {
);

return [ { filter=overallFilter, filterParams=params, extraJoins=[ {
type = "left"
type = "inner"
, subQuery = subquery.sql
, subQueryAlias = subqueryAlias
, subQueryColumn = "id"

0 comments on commit 5597d84

Please sign in to comment.
You can’t perform that action at this time.