Keep confirmed route actions in driver status projection
This commit is contained in:
@@ -18,7 +18,7 @@ interface RouteActionDao {
|
||||
"""
|
||||
SELECT * FROM route_actions
|
||||
WHERE routeId = :routeId
|
||||
AND status IN ('PENDING', 'WAITING_FOR_PHOTOS', 'SYNCING', 'FAILED_RETRYABLE', 'FAILED_CONFLICT', 'FAILED_PERMANENT')
|
||||
AND status IN ('PENDING', 'WAITING_FOR_PHOTOS', 'SYNCING', 'CONFIRMED', 'FAILED_RETRYABLE', 'FAILED_CONFLICT', 'FAILED_PERMANENT')
|
||||
ORDER BY createdAtEpochMillis DESC
|
||||
""",
|
||||
)
|
||||
@@ -27,7 +27,7 @@ interface RouteActionDao {
|
||||
@Query(
|
||||
"""
|
||||
SELECT * FROM route_actions
|
||||
WHERE status IN ('PENDING', 'WAITING_FOR_PHOTOS', 'SYNCING', 'FAILED_RETRYABLE', 'FAILED_CONFLICT', 'FAILED_PERMANENT')
|
||||
WHERE status IN ('PENDING', 'WAITING_FOR_PHOTOS', 'SYNCING', 'CONFIRMED', 'FAILED_RETRYABLE', 'FAILED_CONFLICT', 'FAILED_PERMANENT')
|
||||
ORDER BY createdAtEpochMillis DESC
|
||||
""",
|
||||
)
|
||||
|
||||
@@ -21,14 +21,18 @@ internal val routeActionVisibleStatuses = setOf(
|
||||
RouteActionStatus.FailedPermanent,
|
||||
)
|
||||
|
||||
private val routeActionProjectionStatuses = routeActionVisibleStatuses + RouteActionStatus.Confirmed
|
||||
|
||||
fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>): ProjectedDriverRoute {
|
||||
val visible = actions
|
||||
.filter { it.routeId == route.id && it.status in routeActionVisibleStatuses }
|
||||
val projectable = actions
|
||||
.filter { it.routeId == route.id && it.status in routeActionProjectionStatuses }
|
||||
var projectedRoute = route
|
||||
var loadingWeightPending = false
|
||||
var unloadingWeightPending = false
|
||||
|
||||
visible
|
||||
projectable
|
||||
.sortedWith(compareBy<RouteActionEntity> { it.createdAtEpochMillis }.thenBy { it.clientActionId })
|
||||
.forEach { action ->
|
||||
when (action.action) {
|
||||
@@ -38,7 +42,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
||||
loadingWeight = action.weight,
|
||||
trackingStatus = "active",
|
||||
)
|
||||
loadingWeightPending = true
|
||||
loadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||
}
|
||||
RouteActionType.Finish -> {
|
||||
projectedRoute = projectedRoute.copy(
|
||||
@@ -47,7 +51,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
||||
trackingStatus = "finished",
|
||||
completedAt = action.occurredAt,
|
||||
)
|
||||
unloadingWeightPending = true
|
||||
unloadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user