Lightning.WorkOrders.Query (Lightning v2.14.13-pre1)
View SourceQuery functions for the Lightning.WorkOrders module.
Summary
Functions
Query to calculate the current state of a workorder.
Functions
@spec state_for(Lightning.Run.t()) :: Ecto.Query.t()
Query to calculate the current state of a workorder.
It takes a run, as the state is updated after each run is changed.
The logic is as follows:
- All other Runs that are not in a finished state are considered first.
- The current Run is unioned onto the unfinished runs with a null ordinality.
- The runs are ordered by state in the following order
started > available > claimed > null - The run states are then mapped to the workorder state enum, so
availableandclaimedare both mapped topendingandstartedis mapped torunning
The
nullordinality ensures that the current run is always last in the ordering.