Action schedule
Actions in GG-CE are either:
- Completed
- In progress, or
- Pending (including #227 (closed))
The overview is based on user-selected time period: one day (today, yesterday, tomorrow, pick a date), one week (this week, last week, pick a week), one month (this month, last month, pick a month), one year (this year, last year, pick a year). This sets the date range for querying GG-CE: { fromInclusive: DATE1, toExclusive: DATE2 }
.
We are interested in the following categories:
- Actions completed in the selected period
completedDate >= DATE1 and completedDate < DATE2
- Actions in progress in the selected period
startedDate < DATE2 and (completedDate is null or completedDate > DATE2)
- Actions scheduled in the selected period
notBeforeDate >= DATE1 and notBeforeDate < DATE2
- New actions added in the selected period
createdDate >= DATE1 and createdDate < DATE2
-
Overdue actions in the period
completedDate IS NULL and (notBeforeDate IS NULL or (notBeforeDate >= DATE1 and notBeforeDate < DATE2))
Note: Apparently SQL BETWEEN returns TRUE if the value of test_expression is greater than or equal to the value of begin_expression and less than or equal to the value of end_expression. This is not what we want.
Each category is basically a list (loooooong list) of InventoryActions
, but we are looking for the count of actions in each category grouped by actionNameCode
and the API call to actionSchedule(...)
returns for the specified period the following response:
{
"completed": {
"VIABILITY_TEST": 30,
"actionNameCode2": 30,
"actionNameCode4": 10,
},
"inProgress": { "VIABILITY_TEST": 4, "actionNameCode2": 4, ... },
"scheduled": { ... },
"added": { ... },
"overdue": { ... }
}
API updates
This is for InventoryAction
, but should be abstracted so it works for other AbstractAction
types:
// Returns the action schedule summary as described above
@PostMapping("/schedule")
public ActionScheduleOverview actionSchedule(InventoryActionScheduleFilter filter) { ... }
public static class ActionScheduleOverview {
public Map<String, Number> completed;
public Map<String, Number> inProgress;
...
}
public static class InventoryActionScheduleFilter {
@NotNull public Date fromInclusive; // x >= DATE1
@NotNull public Date toExclusive; // x < DATE2
public Set<String> actionCode;
public InventoryFilter inventory; // Filter for inventoryAction.inventory
}
Page<InventoryActions>
Retrieving The ActionScheduleOverview
provides the summary numbers, the UI will need to load and display the actions in each category. Please add to AbstractActionController
(with no filterCode
support):
// List of completed actions for InventoryActionScheduleFilter
@PostMapping(value = "/action/list/completed", produces = { MediaType.APPLICATION_JSON_VALUE })
public Page<T, F> listCompletedActions(@Parameter(hidden = true) final Pagination page, @RequestBody(required = true) final InventoryActionScheduleFilter filter) throws IOException { ... }
// List of ...
@PostMapping(value = "/action/list/inProgress", produces = { MediaType.APPLICATION_JSON_VALUE })
@PostMapping(value = "/action/list/scheduled", produces = { MediaType.APPLICATION_JSON_VALUE })
@PostMapping(value = "/action/list/added", produces = { MediaType.APPLICATION_JSON_VALUE })
@PostMapping(value = "/action/list/overdue", produces = { MediaType.APPLICATION_JSON_VALUE })