Documentation_Batch_2 - revaturelabs/assignforce-force GitHub Wiki
Introduction
The Batch documentation describes some of the changes and future implementations on the Batch tab. It includes components to create new batches and view batches visually in a timeline.
Base Master Controller
This pattern allows so that Trainer/Room/Batch data should only ever be called from the database once and it minimizes the need to query from the same object and reduce database calls. The afNewBatchAndAvailabilityApexController contains some of the queries to be used and distributed through the afNewBatchAndAvailabilityComponents.cmp via attributes. This controller should distribute lists to each of its child components and also the timeline via an event, because data is queried from the same objects and the number of calls to the database should be limited. After, those lists should be passed on to the server side controllers of the child components receiving those queries in order to apply filtering logic. Filtering logic should be performed on the server-side, not client.
The trainer team recently reworked filtering logic in afAvailListContainerApexController.cls and the logic is calling from the database each time an updateFltersEvent occurs (Changing Training Track, Changing Start Date, or Changing Location) on the afNewBatchForm.cmp, which updates the afAvailabilityListContainer. All filtering seems to be done through multiple queries and loops at the moment, as a result, there are multiple calls to the database. A total of 6 queries each time an event occurs, this will be problematic in regards to governor limits as the number of synchronous query limits are 100. The updateFiltersEvent on the afNewBatchForm.cmp page will end up hitting governor limits eventually with this pattern. For future sprints, this is an issue that needs to be resolved.
When a new batch is created, that new record should be added to an existing attribute that contains the queried data instead of re-querying as the afAvailabilityListContainer apex controller is doing.
Additionally, the apex afTimelineController.cls controller, is performing a query for trainings(batches). This component will need to receive the query from the master controller instead, via an event, as other components are querying from the same object.
Server-side Filtering
Filtering for locations, rooms, and trainers were all moved from the client JavaScript controller to its Apex controller. So the filter logic was moved from the afAvailabilityListContainerController.js to afAvailListContainerApexController.
Scheduling batch over daylight savings fix
Prior to the fix, scheduling a batch over daylight savings would cause the end date to end on a Thursday rather than on Friday. To fix this issue we used an if statement to check if the current end date ended on a Thursday using the condition endDate.getUTCDate === 4. endDate.getUTCDate being the calculated end date from the start date and 4 being Thursday since getUTCDate returns the days of the week from 0 to 6 starting on Sunday. Once the condition is met, we added 1 to the date variable so that it would be Friday instead of Thursday.
Future Implementations
If a batch is planned on the start date, it shouldn’t be confirmed automatically. Needs to be done manually
- An approval process to handle this need.
Show toast if an unavailable room is selected when creating batch
Batch cannot be scheduled for a trainer OR co-trainer who has PTO during that time frame
Batch Scheduling Capacity Planning
- Batch Training Target field should be added to the afNewBatchForm
- Training Target field should be compared to the selected room capacity
- Display a toast (message) if the training target is larger than room capacity