Compare commits
3
Commits
v1.0.44-47
...
v1.0.44-49
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e811b4bc43 | ||
|
|
5d3b355163 | ||
|
|
81f3b05653 |
@@ -34,7 +34,7 @@ android {
|
|||||||
applicationId = "pl.firmatpp.kierowca"
|
applicationId = "pl.firmatpp.kierowca"
|
||||||
minSdk = 26
|
minSdk = 26
|
||||||
targetSdk = 35
|
targetSdk = 35
|
||||||
versionCode = 47
|
versionCode = 49
|
||||||
versionName = "1.0.44"
|
versionName = "1.0.44"
|
||||||
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
setProperty("archivesBaseName", "pl.firmatpp.kierowca")
|
||||||
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ interface RouteActionDao {
|
|||||||
"""
|
"""
|
||||||
SELECT * FROM route_actions
|
SELECT * FROM route_actions
|
||||||
WHERE routeId = :routeId
|
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
|
ORDER BY createdAtEpochMillis DESC
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
@@ -28,6 +28,14 @@ interface RouteActionDao {
|
|||||||
"""
|
"""
|
||||||
SELECT * FROM route_actions
|
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', 'FAILED_RETRYABLE', 'FAILED_CONFLICT', 'FAILED_PERMANENT')
|
||||||
|
OR clientActionId IN (
|
||||||
|
SELECT confirmed.clientActionId
|
||||||
|
FROM route_actions AS confirmed
|
||||||
|
WHERE confirmed.status = 'CONFIRMED'
|
||||||
|
AND confirmed.routeId = route_actions.routeId
|
||||||
|
ORDER BY confirmed.createdAtEpochMillis DESC
|
||||||
|
LIMIT 2
|
||||||
|
)
|
||||||
ORDER BY createdAtEpochMillis DESC
|
ORDER BY createdAtEpochMillis DESC
|
||||||
""",
|
""",
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -21,14 +21,18 @@ internal val routeActionVisibleStatuses = setOf(
|
|||||||
RouteActionStatus.FailedPermanent,
|
RouteActionStatus.FailedPermanent,
|
||||||
)
|
)
|
||||||
|
|
||||||
|
private val routeActionProjectionStatuses = routeActionVisibleStatuses + RouteActionStatus.Confirmed
|
||||||
|
|
||||||
fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>): ProjectedDriverRoute {
|
fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>): ProjectedDriverRoute {
|
||||||
val visible = actions
|
val visible = actions
|
||||||
.filter { it.routeId == route.id && it.status in routeActionVisibleStatuses }
|
.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 projectedRoute = route
|
||||||
var loadingWeightPending = false
|
var loadingWeightPending = false
|
||||||
var unloadingWeightPending = false
|
var unloadingWeightPending = false
|
||||||
|
|
||||||
visible
|
projectable
|
||||||
.sortedWith(compareBy<RouteActionEntity> { it.createdAtEpochMillis }.thenBy { it.clientActionId })
|
.sortedWith(compareBy<RouteActionEntity> { it.createdAtEpochMillis }.thenBy { it.clientActionId })
|
||||||
.forEach { action ->
|
.forEach { action ->
|
||||||
when (action.action) {
|
when (action.action) {
|
||||||
@@ -38,7 +42,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
|||||||
loadingWeight = action.weight,
|
loadingWeight = action.weight,
|
||||||
trackingStatus = "active",
|
trackingStatus = "active",
|
||||||
)
|
)
|
||||||
loadingWeightPending = true
|
loadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||||
}
|
}
|
||||||
RouteActionType.Finish -> {
|
RouteActionType.Finish -> {
|
||||||
projectedRoute = projectedRoute.copy(
|
projectedRoute = projectedRoute.copy(
|
||||||
@@ -47,7 +51,7 @@ fun projectDriverRoute(route: DriverRouteDto, actions: List<RouteActionEntity>):
|
|||||||
trackingStatus = "finished",
|
trackingStatus = "finished",
|
||||||
completedAt = action.occurredAt,
|
completedAt = action.occurredAt,
|
||||||
)
|
)
|
||||||
unloadingWeightPending = true
|
unloadingWeightPending = action.status != RouteActionStatus.Confirmed
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -57,6 +57,22 @@ class DriverRouteProjectionTest {
|
|||||||
assertEquals("finished", projection.route.trackingStatus)
|
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
|
@Test
|
||||||
fun conflictKeepsLocalRouteValuesAndMarksStageAsAttention() {
|
fun conflictKeepsLocalRouteValuesAndMarksStageAsAttention() {
|
||||||
val projection = projectDriverRoute(
|
val projection = projectDriverRoute(
|
||||||
|
|||||||
Reference in New Issue
Block a user