package com.tencent.liteav.demo.superplayer.database.dao

import androidx.room.Dao
import androidx.room.Insert
import androidx.room.OnConflictStrategy.REPLACE
import androidx.room.Query
import com.tencent.liteav.demo.superplayer.database.entity.History
import kotlinx.coroutines.flow.Flow

@Dao
public interface HistoryDao {
    @Query("SELECT * FROM history WHERE course_id = :courseId")
    fun getById(courseId: String): Flow<List<History>>

    @Insert(onConflict = REPLACE)
    fun insertHistory(history: History)

    @Insert
    fun insertHistories(vararg histories: History)

    @Query("SELECT COUNT(DISTINCT(section_id)) FROM History WHERE date = :date")
    fun queryTodayEpisodeHistory(date: String): Flow<Int>

    @Query("SELECT * FROM History WHERE date = :date")
    fun queryTodayDurationHistory(date: String): Flow<List<History>>
}