package pl.firmatpp.kierowca.data.upload

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

object RoutePointStatus {
    const val Pending = "PENDING"
    const val Syncing = "SYNCING"
    const val Confirmed = "CONFIRMED"
    const val FailedRetryable = "FAILED_RETRYABLE"
    const val FailedPermanent = "FAILED_PERMANENT"
}

@Entity(
    tableName = "route_points",
    indices = [
        Index(value = ["routeId"]),
        Index(value = ["status"]),
        Index(value = ["routeId", "status"]),
    ],
)
data class RoutePointEntity(
    @PrimaryKey val clientPointId: String,
    val routeId: String,
    val driverId: String,
    val lat: Double,
    val lon: Double,
    val accuracy: Double,
    val speed: Double?,
    val bearing: Double?,
    val timestamp: Long,
    val battery: Int?,
    val charging: Boolean,
    val status: String = RoutePointStatus.Pending,
    val attemptCount: Int = 0,
    val lastError: String? = null,
    val createdAtEpochMillis: Long = System.currentTimeMillis(),
    val updatedAtEpochMillis: Long = System.currentTimeMillis(),
)
