Compare commits
2
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5d3b355163 | ||
|
|
81f3b05653 |
@@ -34,7 +34,7 @@ android {
|
||||
applicationId = "pl.firmatpp.kierowca"
|
||||
minSdk = 26
|
||||
targetSdk = 35
|
||||
versionCode = 47
|
||||
versionCode = 48
|
||||
versionName = "1.0.44"
|
||||
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||
|
||||
@@ -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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,6 +57,22 @@ class DriverRouteProjectionTest {
|
||||
assertEquals("finished", projection.route.trackingStatus)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun confirmedFinishStillProjectsPlannedRouteAsFinishedWithoutSyncCallout() {
|
||||
val projection = projectDriverRoute(
|
||||
route = route(status = "ZAPLANOWANA"),
|
||||
actions = listOf(
|
||||
action(RouteActionType.Finish, RouteActionStatus.Confirmed, weight = 11.8, createdAt = 2000),
|
||||
),
|
||||
)
|
||||
|
||||
assertEquals("ZAKOŃCZONA", projection.route.status)
|
||||
assertEquals(11.8, projection.route.unloadingWeight)
|
||||
assertEquals("finished", projection.route.trackingStatus)
|
||||
assertFalse(projection.unloadingWeightPending)
|
||||
assertEquals(emptyList<RouteActionEntity>(), projection.visibleActions)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun conflictKeepsLocalRouteValuesAndMarksStageAsAttention() {
|
||||
val projection = projectDriverRoute(
|
||||
|
||||
Reference in New Issue
Block a user