package pl.firmatpp.kierowca.data.upload

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

@Entity(
    tableName = "dispatch_sheet_uploads",
    indices = [
        Index(value = ["workDate"]),
        Index(value = ["status"]),
    ],
)
data class DispatchSheetUploadEntity(
    @PrimaryKey val clientRequestId: String,
    val workDate: String,
    val replacePhotoId: String?,
    val localPath: String,
    val source: String,
    val takenAt: String?,
    val latitude: Double?,
    val longitude: Double?,
    val locationAccuracyMeters: Double?,
    val mimeType: String,
    val size: Long,
    val contentSha256: String,
    val status: String = PhotoUploadStatus.Pending.storageValue,
    val progress: Int = 0,
    val attemptCount: Int = 0,
    val lastError: String? = null,
    val serverPhotoId: String? = null,
    val createdAtEpochMillis: Long = System.currentTimeMillis(),
    val updatedAtEpochMillis: Long = System.currentTimeMillis(),
) {
    val statusType: PhotoUploadStatus
        get() = PhotoUploadStatus.fromStorage(status)
}
