LiveActivityLaunchEntity.kt

// EV Supervision Lite — built by Kevin Vavelin, Codetics
// https://codetics.fr
// Copyright (c) 2026 Kevin Vavelin, Codetics
// SPDX-License-Identifier: LicenseRef-Codetics-Attribution-1.0

package fr.codetics.ev_server.models.entities

import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.persistence.Table
import java.time.Instant
import java.util.UUID
import org.springframework.data.mongodb.core.mapping.Document

/** Records that the server already started the Live Activity of a session, so it never starts it twice. */
@Entity
@Table(name = "live_activity_launches")
@Document("live_activity_launches")
class LiveActivityLaunchEntity(
    @Id var id: String = "",
    var tenantId: UUID = UUID.randomUUID(),
    var transactionId: Int = 0,
    var launchedAt: Instant = Instant.now(),
) {
    companion object {
        fun key(tenant: UUID, transaction: Int) = "$tenant:$transaction"
    }
}