Reorganize navigation

This commit is contained in:
Koitharu
2023-07-03 17:19:42 +03:00
parent fb674b6028
commit 4739da2774
33 changed files with 418 additions and 136 deletions

View File

@@ -19,6 +19,10 @@ abstract class SuggestionDao {
@Query("SELECT * FROM suggestions ORDER BY relevance DESC LIMIT :limit")
abstract fun observeAll(limit: Int): Flow<List<SuggestionWithManga>>
@Transaction
@Query("SELECT * FROM suggestions ORDER BY RANDOM() LIMIT 1")
abstract suspend fun getRandom(): SuggestionWithManga?
@Query("SELECT COUNT(*) FROM suggestions")
abstract suspend fun count(): Int

View File

@@ -10,6 +10,7 @@ import org.koitharu.kotatsu.core.db.entity.toMangaTags
import org.koitharu.kotatsu.core.util.ext.mapItems
import org.koitharu.kotatsu.parsers.model.Manga
import org.koitharu.kotatsu.suggestions.data.SuggestionEntity
import org.koitharu.kotatsu.suggestions.data.SuggestionWithManga
import javax.inject.Inject
class SuggestionRepository @Inject constructor(
@@ -28,6 +29,10 @@ class SuggestionRepository @Inject constructor(
}
}
suspend fun getRandom(): SuggestionWithManga? {
return db.suggestionDao.getRandom()
}
suspend fun clear() {
db.suggestionDao.deleteAll()
}