Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

optimize ProcessListVRS to reuse existing Hours if possible. Issue #154 #223

Merged
merged 10 commits into from
Dec 5, 2016
Prev Previous commit
Next Next commit
when JRS's processed by scheduler or trigger, also have VRS's know th…
…is (i.e., whether to re-evaluate all shifts or just future shifts)
  • Loading branch information
David Habib committed Nov 30, 2016
commit 7da48c91796b364737a363653680976fbdde7971
11 changes: 7 additions & 4 deletions src/classes/VOL_JRS.cls
Original file line number Diff line number Diff line change
Expand Up @@ -132,25 +132,28 @@ public with sharing class VOL_JRS {
listVRS = [select Id, Name, Contact__c, Schedule_Start_Date_Time__c, Schedule_End_Date__c, Duration__c,
Weekly_Occurrence__c, Days_Of_Week__c, Volunteer_Job__c, Volunteer_Hours_Status__c, Number_of_Volunteers__c, Comments__c
from Volunteer_Recurrence_Schedule__c where Volunteer_Job__c in : setJobId];
VOL_VRS.ProcessListVRS(listVRS);
VOL_VRS.ProcessListVRS(listVRS, fReviewAllShifts);
} else {
ProcessListVRSFuture(setJobId);
ProcessListVRSFuture(setJobId, fReviewAllShifts);
}
}

//******************************************************************************************************
// Process all the VRS's for the set of Job's. This Future cover was created to avoid
// hitting apex system statement limits that we would hit if there were many VRS's for a given job.
// fReviewAllShifts parameter specifies whether called from the trigger on JRS's, in
// which case we should review all shifts under the Jobs, or from the scheduled batch,
// in which case we only need to be looking to add additional shifts in the future.
@future (callout=false)
private static void ProcessListVRSFuture(set<ID> setJobId) {
private static void ProcessListVRSFuture(set<ID> setJobId, boolean fReviewAllShifts) {

list<Volunteer_Recurrence_Schedule__c> listVRS = new list<Volunteer_Recurrence_Schedule__c>();
listVRS = [select Id, Name, Contact__c, Schedule_Start_Date_Time__c, Schedule_End_Date__c, Duration__c,
Weekly_Occurrence__c, Days_Of_Week__c, Volunteer_Job__c, Volunteer_Hours_Status__c, Number_of_Volunteers__c, Comments__c
from Volunteer_Recurrence_Schedule__c where Volunteer_Job__c in : setJobId];

// process the VRS's to create hours as needed.
VOL_VRS.ProcessListVRS(listVRS);
VOL_VRS.ProcessListVRS(listVRS, fReviewAllShifts);
}


Expand Down