diff --git a/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt b/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt index 1f12dce..b47749b 100644 --- a/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt +++ b/app/src/main/kotlin/it/vfsfitvnm/vimusic/Database.kt @@ -300,16 +300,11 @@ interface Database { fun isImportedPlaylist(browseId: String): Flow @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 fun trending(now: Long = System.currentTimeMillis()): Flow -// @Transaction -// @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 - - @Insert(onConflict = OnConflictStrategy.ABORT) + @Insert fun insert(event: Event) @Insert(onConflict = OnConflictStrategy.REPLACE)