Skip to content

Commit

Permalink
change the closedStatusValues variable scope so that the variable is …
Browse files Browse the repository at this point in the history
…available for binding translation when the query is executed to retrieve the locator
  • Loading branch information
daniel-fuller committed Jul 5, 2022
1 parent d071cf7 commit 397f6b4
Showing 1 changed file with 19 additions and 9 deletions.
28 changes: 19 additions & 9 deletions force-app/main/default/classes/RD2_OpportunityEvaluation_BATCH.cls
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,16 @@ public without sharing class RD2_OpportunityEvaluation_BATCH
set;
}

private Set<String> closedStatusValues {
get {
if (closedStatusValues == null) {
closedStatusValues = RD2_StatusMapper.getInstance().getClosedStatusValues();
}
return closedStatusValues;
}
set;
}

/**
* @description Count of RD's processed by the batch
*/
Expand Down Expand Up @@ -207,13 +217,7 @@ public without sharing class RD2_OpportunityEvaluation_BATCH

validateStatusField();

String query = getRDBatchQuery();

if (isConcurrentBatch) {
new UTIL_BatchJobService().logConcurrentBatchError(batchClassName, ERR_Handler_API.Context.RD);
query += ' LIMIT 0';
}
return Database.getQueryLocator(query);
return Database.getQueryLocator(getRDBatchQuery());
}

/**
Expand Down Expand Up @@ -242,9 +246,14 @@ public without sharing class RD2_OpportunityEvaluation_BATCH
@TestVisible
private String getRDBatchQuery() {
String rdFilterWhereClause;
Integer queryLimit;
if (closedFilterEnabled) {
Set<String> closedStatusValues = RD2_StatusMapper.getInstance().getClosedStatusValues();
rdFilterWhereClause = 'Status__c NOT IN:' + closedStatusValues;
rdFilterWhereClause = 'Status__c NOT IN :closedStatusValues';
}

if (isConcurrentBatch) {
new UTIL_BatchJobService().logConcurrentBatchError(batchClassName, ERR_Handler_API.Context.RD);
queryLimit = 0;
}

return new UTIL_Query()
Expand All @@ -253,6 +262,7 @@ public without sharing class RD2_OpportunityEvaluation_BATCH
new Set<String>{ 'Id' }
)
.withWhere(rdFilterWhereClause)
.withLimit(queryLimit)
.build();
}

Expand Down

0 comments on commit 397f6b4

Please sign in to comment.