Fix trending song query

This commit is contained in:
vfsfitvnm 2022-10-05 15:27:50 +02:00
parent aafb8f036d
commit ed7ee1b6c0

View file

@ -300,16 +300,11 @@ interface Database {
fun isImportedPlaylist(browseId: String): Flow<Boolean> fun isImportedPlaylist(browseId: String): Flow<Boolean>
@Transaction @Transaction
@Query("SELECT Song.* FROM Event JOIN Song ON Song.id = songId GROUP BY songId ORDER BY SUM(playTime / ((:now - timestamp) / 86400000.0)) LIMIT 1") @Query("SELECT Song.* FROM Event JOIN Song ON Song.id = songId GROUP BY songId ORDER BY SUM(CAST(playTime AS REAL) / (((:now - timestamp) / 86400000) + 1)) DESC LIMIT 1")
@RewriteQueriesToDropUnusedColumns @RewriteQueriesToDropUnusedColumns
fun trending(now: Long = System.currentTimeMillis()): Flow<DetailedSong?> fun trending(now: Long = System.currentTimeMillis()): Flow<DetailedSong?>
// @Transaction @Insert
// @Query("SELECT songId FROM Event GROUP BY songId ORDER BY SUM(playTime / ((:now - timestamp) / 86400000.0)) LIMIT 1")
// @RewriteQueriesToDropUnusedColumns
// fun trending(now: Long = System.currentTimeMillis()): Flow<DetailedSong?>
@Insert(onConflict = OnConflictStrategy.ABORT)
fun insert(event: Event) fun insert(event: Event)
@Insert(onConflict = OnConflictStrategy.REPLACE) @Insert(onConflict = OnConflictStrategy.REPLACE)