package com.placeholder.sherpai2.data.local.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy
import androidx.room.Query
import com.placeholder.sherpai2.data.local.entity.EventEntity

@Dao
interface EventDao {

    @Insert(onConflict = OnConflictStrategy.REPLACE)
    suspend fun insert(event: EventEntity)

    /**
     * Find events covering a timestamp.
     *
     * This is the backbone of auto-tagging by date.
     */
    @Query("""
        SELECT * FROM events
        WHERE :timestamp BETWEEN startDate AND endDate
        AND isHidden = 0
    """)
    suspend fun findEventsForTimestamp(timestamp: Long): List<EventEntity>
}
