package pl.firmatpp.kierowca.data.upload

import androidx.room.Entity
import androidx.room.Index
import androidx.room.PrimaryKey

object RouteActionStatus {
    const val Pending = "PENDING"
    const val WaitingForPhotos = "WAITING_FOR_PHOTOS"
    const val Syncing = "SYNCING"
    const val Confirmed = "CONFIRMED"
    const val FailedRetryable = "FAILED_RETRYABLE"
    const val FailedPermanent = "FAILED_PERMANENT"
    const val FailedConflict = "FAILED_CONFLICT"
}

object RouteActionType {
    const val Start = "start"
    const val Finish = "finish"
}

@Entity(
    tableName = "route_actions",
    indices = [
        Index(value = ["routeId"]),
        Index(value = ["status"]),
    ],
)
data class RouteActionEntity(
    @PrimaryKey val clientActionId: String,
    val routeId: String,
    val action: String,
    val weight: Double,
    val occurredAt: String,
    val photoClientRequestIdsJson: String,
    val status: String = RouteActionStatus.Pending,
    val attemptCount: Int = 0,
    val lastError: String? = null,
    val createdAtEpochMillis: Long = System.currentTimeMillis(),
    val updatedAtEpochMillis: Long = System.currentTimeMillis(),
)
