Skip to content

Commit 6830f0b

Browse files
authored
Merge pull request #114 from kdroidFilter/feat/book-editions
feat(dao): getBookEditions (source and license per edition)
2 parents c9d443f + b57ebd8 commit 6830f0b

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

‎dao/src/commonMain/kotlin/io/github/kdroidfilter/seforimlibrary/dao/repository/SeforimRepository.kt‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2748,6 +2748,13 @@ class SeforimRepository(databasePath: String, private val driver: SqlDriver) : L
27482748
)
27492749
}
27502750

2751+
/** A book's editions, each with its source and license (several when its text joins editions). */
2752+
suspend fun getBookEditions(bookId: Long): List<BookEdition> = withContext(Dispatchers.IO) {
2753+
database.licenseQueriesQueries.selectEditionsByBookId(bookId).executeAsList().map {
2754+
BookEdition(it.title, it.heTitle, it.sourceUrl, it.licenseCode)
2755+
}
2756+
}
2757+
27512758
/** Every author with its aliases and number of books, for the lookup index. */
27522759
suspend fun getAuthorsForLookup(): List<AuthorLookupEntry> = withContext(Dispatchers.IO) {
27532760
val aliases = database.authorQueriesQueries.selectAllAliases().executeAsList()
@@ -2903,6 +2910,14 @@ data class AuthorBio(
29032910
val licenseCode: String,
29042911
)
29052912

2913+
data class BookEdition(
2914+
val title: String,
2915+
val heTitle: String?,
2916+
val sourceUrl: String?,
2917+
/** CC-BY-SA, Public Domain, … or unknown. */
2918+
val licenseCode: String,
2919+
)
2920+
29062921
data class AuthorLookupEntry(
29072922
val id: Long,
29082923
val name: String,

0 commit comments

Comments
 (0)