diff --git a/komga/src/main/kotlin/org/gotson/komga/application/tasks/TaskReceiver.kt b/komga/src/main/kotlin/org/gotson/komga/application/tasks/TaskReceiver.kt index b3bbff033..432966fb3 100644 --- a/komga/src/main/kotlin/org/gotson/komga/application/tasks/TaskReceiver.kt +++ b/komga/src/main/kotlin/org/gotson/komga/application/tasks/TaskReceiver.kt @@ -44,7 +44,7 @@ class TaskReceiver( } fun analyzeUnknownAndOutdatedBooks(library: Library) { - bookRepository.findAllId( + bookRepository.findAllIds( BookSearch( libraryIds = listOf(library.id), mediaStatus = listOf(Media.Status.UNKNOWN, Media.Status.OUTDATED) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookMetadataRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookMetadataRepository.kt index 6b5223c3a..37966bf2a 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookMetadataRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookMetadataRepository.kt @@ -5,13 +5,15 @@ import org.gotson.komga.domain.model.BookMetadata interface BookMetadataRepository { fun findById(bookId: String): BookMetadata fun findByIdOrNull(bookId: String): BookMetadata? - fun findByIds(bookIds: Collection): Collection + + fun findAllByIds(bookIds: Collection): Collection fun insert(metadata: BookMetadata) - fun insertMany(metadatas: Collection) + fun insert(metadatas: Collection) + fun update(metadata: BookMetadata) - fun updateMany(metadatas: Collection) + fun update(metadatas: Collection) fun delete(bookId: String) - fun deleteByBookIds(bookIds: Collection) + fun delete(bookIds: Collection) } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookRepository.kt index 73a126ae1..1123c83d0 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/BookRepository.kt @@ -11,28 +11,28 @@ interface BookRepository { fun findByIdOrNull(bookId: String): Book? fun findByLibraryIdAndUrlOrNull(libraryId: String, url: URL): Book? - fun findBySeriesId(seriesId: String): Collection fun findAll(): Collection + fun findAllBySeriesId(seriesId: String): Collection fun findAll(bookSearch: BookSearch): Collection fun findAll(bookSearch: BookSearch, pageable: Pageable): Page - fun getLibraryId(bookId: String): String? - fun findFirstIdInSeries(seriesId: String): String? + fun getLibraryIdOrNull(bookId: String): String? + fun findFirstIdInSeriesOrNull(seriesId: String): String? - fun findAllIdBySeriesId(seriesId: String): Collection - fun findAllIdBySeriesIds(seriesIds: Collection): Collection - fun findAllIdByLibraryId(libraryId: String): Collection - fun findAllId(bookSearch: BookSearch, sort: Sort): Collection - fun findAllIdByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection): Collection - fun findAllIdByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection + fun findAllIdsBySeriesId(seriesId: String): Collection + fun findAllIdsBySeriesIds(seriesIds: Collection): Collection + fun findAllIdsByLibraryId(libraryId: String): Collection + fun findAllIdsByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection): Collection + fun findAllIdsByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection + fun findAllIds(bookSearch: BookSearch, sort: Sort): Collection fun insert(book: Book) - fun insertMany(books: Collection) + fun insert(books: Collection) fun update(book: Book) - fun updateMany(books: Collection) + fun update(books: Collection) fun delete(bookId: String) - fun deleteByBookIds(bookIds: Collection) + fun delete(bookIds: Collection) fun deleteAll() fun count(): Long diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/KomgaUserRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/KomgaUserRepository.kt index 3ff0ecf98..3afac7ab3 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/KomgaUserRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/KomgaUserRepository.kt @@ -5,15 +5,16 @@ import org.gotson.komga.domain.model.KomgaUser interface KomgaUserRepository { fun count(): Long - fun findAll(): Collection fun findByIdOrNull(id: String): KomgaUser? + fun findByEmailIgnoreCase(email: String): KomgaUser? + + fun findAll(): Collection + + fun existsByEmailIgnoreCase(email: String): Boolean fun insert(user: KomgaUser) fun update(user: KomgaUser) fun delete(userId: String) fun deleteAll() - - fun existsByEmailIgnoreCase(email: String): Boolean - fun findByEmailIgnoreCase(email: String): KomgaUser? } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/LibraryRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/LibraryRepository.kt index 8b6eb63d1..edf7bc26b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/LibraryRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/LibraryRepository.kt @@ -3,10 +3,11 @@ package org.gotson.komga.domain.persistence import org.gotson.komga.domain.model.Library interface LibraryRepository { - fun findByIdOrNull(libraryId: String): Library? fun findById(libraryId: String): Library + fun findByIdOrNull(libraryId: String): Library? + fun findAll(): Collection - fun findAllById(libraryIds: Collection): Collection + fun findAllByIds(libraryIds: Collection): Collection fun delete(libraryId: String) fun deleteAll() diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/MediaRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/MediaRepository.kt index 250873059..84dab34a6 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/MediaRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/MediaRepository.kt @@ -4,11 +4,13 @@ import org.gotson.komga.domain.model.Media interface MediaRepository { fun findById(bookId: String): Media + fun getPagesSize(bookId: String): Int fun getPagesSizes(bookIds: Collection): Collection> fun insert(media: Media) - fun insertMany(medias: Collection) + fun insert(medias: Collection) + fun update(media: Media) fun delete(bookId: String) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadListRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadListRepository.kt index 551ab5f47..f9c68b5a0 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadListRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadListRepository.kt @@ -6,7 +6,8 @@ import org.springframework.data.domain.Pageable interface ReadListRepository { fun findByIdOrNull(readListId: String): ReadList? - fun findAll(search: String? = null, pageable: Pageable): Page + + fun searchAll(search: String? = null, pageable: Pageable): Page /** * Find one ReadList by readListId, @@ -18,13 +19,13 @@ interface ReadListRepository { * Find all ReadList with at least one Book belonging to the provided belongsToLibraryIds, * optionally with only bookIds filtered by the provided filterOnLibraryIds. */ - fun findAllByLibraries(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String? = null, pageable: Pageable): Page + fun findAllByLibraryIds(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String? = null, pageable: Pageable): Page /** * Find all ReadList that contains the provided containsBookId, * optionally with only bookIds filtered by the provided filterOnLibraryIds. */ - fun findAllByBook(containsBookId: String, filterOnLibraryIds: Collection?): Collection + fun findAllContainingBookId(containsBookId: String, filterOnLibraryIds: Collection?): Collection fun findByNameOrNull(name: String): ReadList? @@ -32,11 +33,11 @@ interface ReadListRepository { fun update(readList: ReadList) fun removeBookFromAll(bookId: String) - fun removeBookFromAll(bookIds: Collection) + fun removeBooksFromAll(bookIds: Collection) fun delete(readListId: String) - fun deleteAll() fun deleteEmpty() + fun existsByName(name: String): Boolean } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadProgressRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadProgressRepository.kt index 11b884353..7760d9958 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadProgressRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReadProgressRepository.kt @@ -3,13 +3,14 @@ package org.gotson.komga.domain.persistence import org.gotson.komga.domain.model.ReadProgress interface ReadProgressRepository { + fun findByBookIdAndUserIdOrNull(bookId: String, userId: String): ReadProgress? + fun findAll(): Collection - fun findByBookIdAndUserId(bookId: String, userId: String): ReadProgress? - fun findByUserId(userId: String): Collection - fun findByBookId(bookId: String): Collection + fun findAllByUserId(userId: String): Collection + fun findAllByBookId(bookId: String): Collection fun save(readProgress: ReadProgress) - fun saveAll(readProgresses: Collection) + fun save(readProgresses: Collection) fun delete(bookId: String, userId: String) fun deleteByUserId(userId: String) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt index 8635676f1..fa988d0e9 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt @@ -6,17 +6,17 @@ import org.springframework.data.domain.Pageable import java.time.LocalDate interface ReferentialRepository { - fun findAuthorsByName(search: String, filterOnLibraryIds: Collection?): List - fun findAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection?): List - fun findAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection?): List - fun findAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection?): List - fun findAuthorsNamesByName(search: String, filterOnLibraryIds: Collection?): List - fun findAuthorsRoles(filterOnLibraryIds: Collection?): List + fun findAllAuthorsByName(search: String, filterOnLibraryIds: Collection?): List + fun findAllAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection?): List + fun findAllAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection?): List + fun findAllAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection?): List + fun findAllAuthorsNamesByName(search: String, filterOnLibraryIds: Collection?): List + fun findAllAuthorsRoles(filterOnLibraryIds: Collection?): List - fun findAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection?, pageable: Pageable): Page - fun findAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page - fun findAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page - fun findAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page + fun findAllAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection?, pageable: Pageable): Page + fun findAllAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page + fun findAllAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page + fun findAllAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page fun findAllGenres(filterOnLibraryIds: Collection?): Set fun findAllGenresByLibrary(libraryId: String, filterOnLibraryIds: Collection?): Set diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesCollectionRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesCollectionRepository.kt index 9fe4edb06..4f0721311 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesCollectionRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesCollectionRepository.kt @@ -6,7 +6,8 @@ import org.springframework.data.domain.Pageable interface SeriesCollectionRepository { fun findByIdOrNull(collectionId: String): SeriesCollection? - fun findAll(search: String? = null, pageable: Pageable): Page + + fun searchAll(search: String? = null, pageable: Pageable): Page /** * Find one SeriesCollection by collectionId, @@ -18,13 +19,13 @@ interface SeriesCollectionRepository { * Find all SeriesCollection with at least one Series belonging to the provided belongsToLibraryIds, * optionally with only seriesId filtered by the provided filterOnLibraryIds. */ - fun findAllByLibraries(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String? = null, pageable: Pageable): Page + fun findAllByLibraryIds(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String? = null, pageable: Pageable): Page /** * Find all SeriesCollection that contains the provided containsSeriesId, * optionally with only seriesId filtered by the provided filterOnLibraryIds. */ - fun findAllBySeries(containsSeriesId: String, filterOnLibraryIds: Collection?): Collection + fun findAllContainingSeriesId(containsSeriesId: String, filterOnLibraryIds: Collection?): Collection fun findByNameOrNull(name: String): SeriesCollection? @@ -35,8 +36,8 @@ interface SeriesCollectionRepository { fun removeSeriesFromAll(seriesIds: Collection) fun delete(collectionId: String) - fun deleteAll() fun deleteEmpty() + fun existsByName(name: String): Boolean } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt index 6b9807124..0bc6da220 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/SeriesRepository.kt @@ -6,24 +6,24 @@ import java.net.URL interface SeriesRepository { fun findByIdOrNull(seriesId: String): Series? - fun findByLibraryIdAndUrl(libraryId: String, url: URL): Series? + fun findByLibraryIdAndUrlOrNull(libraryId: String, url: URL): Series? fun findAll(): Collection - fun findByLibraryId(libraryId: String): Collection - fun findByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection): Collection + fun findAllByLibraryId(libraryId: String): Collection + fun findAllByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection): Collection + fun findAllByTitle(title: String): Collection fun findAll(search: SeriesSearch): Collection - fun findByTitle(title: String): Collection fun getLibraryId(seriesId: String): String? - fun findAllIdByLibraryId(libraryId: String): Collection + fun findAllIdsByLibraryId(libraryId: String): Collection fun insert(series: Series) fun update(series: Series) fun delete(seriesId: String) + fun delete(seriesIds: Collection) fun deleteAll() - fun deleteAll(seriesIds: Collection) fun count(): Long } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailBookRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailBookRepository.kt index b78c071cf..ac08783e8 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailBookRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailBookRepository.kt @@ -3,9 +3,10 @@ package org.gotson.komga.domain.persistence import org.gotson.komga.domain.model.ThumbnailBook interface ThumbnailBookRepository { - fun findByBookId(bookId: String): Collection - fun findByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection - fun findSelectedByBookId(bookId: String): ThumbnailBook? + fun findSelectedByBookIdOrNull(bookId: String): ThumbnailBook? + + fun findAllByBookId(bookId: String): Collection + fun findAllByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection fun insert(thumbnail: ThumbnailBook) fun update(thumbnail: ThumbnailBook) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailSeriesRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailSeriesRepository.kt index bf40da5d1..9394796f2 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailSeriesRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ThumbnailSeriesRepository.kt @@ -3,8 +3,9 @@ package org.gotson.komga.domain.persistence import org.gotson.komga.domain.model.ThumbnailSeries interface ThumbnailSeriesRepository { - fun findBySeriesId(seriesId: String): Collection - fun findSelectedBySeriesId(seriesId: String): ThumbnailSeries? + fun findSelectedBySeriesIdOrNull(seriesId: String): ThumbnailSeries? + + fun findAllBySeriesId(seriesId: String): Collection fun insert(thumbnail: ThumbnailSeries) fun markSelected(thumbnail: ThumbnailSeries) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/TransientBookRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/TransientBookRepository.kt index 92a376a8f..5907e86ed 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/TransientBookRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/TransientBookRepository.kt @@ -3,7 +3,7 @@ package org.gotson.komga.domain.persistence import org.gotson.komga.domain.model.BookWithMedia interface TransientBookRepository { - fun findById(transientBookId: String): BookWithMedia? + fun findByIdOrNull(transientBookId: String): BookWithMedia? fun save(transientBook: BookWithMedia) - fun saveAll(transientBooks: Collection) + fun save(transientBooks: Collection) } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookConverter.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookConverter.kt index 70e3a2a8d..d093f30e3 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookConverter.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookConverter.kt @@ -52,7 +52,7 @@ class BookConverter( private val skippedRepairs = mutableListOf() fun getConvertibleBookIds(library: Library): Collection = - bookRepository.findAllIdByLibraryIdAndMediaTypes(library.id, convertibleTypes) + bookRepository.findAllIdsByLibraryIdAndMediaTypes(library.id, convertibleTypes) fun convertToCbz(book: Book) { if (!libraryRepository.findById(book.libraryId).convertToCbz) @@ -131,7 +131,7 @@ class BookConverter( fun getMismatchedExtensionBookIds(library: Library): Collection = mediaTypeToExtension.flatMap { (mediaType, extension) -> - bookRepository.findAllIdByLibraryIdAndMismatchedExtension(library.id, mediaType, extension) + bookRepository.findAllIdsByLibraryIdAndMismatchedExtension(library.id, mediaType, extension) } fun repairExtension(book: Book) { diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookImporter.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookImporter.kt index 574e9e425..f4a4135e7 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookImporter.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookImporter.kt @@ -122,12 +122,12 @@ class BookImporter( } // copy read progress - readProgressRepository.findByBookId(upgradedBookId) + readProgressRepository.findAllByBookId(upgradedBookId) .map { it.copy(bookId = importedBook.id) } .forEach { readProgressRepository.save(it) } // replace upgraded book by imported book in read lists - readListRepository.findAllByBook(upgradedBookId, filterOnLibraryIds = null) + readListRepository.findAllContainingBookId(upgradedBookId, filterOnLibraryIds = null) .forEach { rl -> readListRepository.update( rl.copy( diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt index 3b1b000c2..ed82a4c52 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/BookLifecycle.kt @@ -70,7 +70,7 @@ class BookLifecycle( } ThumbnailBook.Type.SIDECAR -> { // delete existing thumbnail with the same url - thumbnailBookRepository.findByBookIdAndType(thumbnail.bookId, ThumbnailBook.Type.SIDECAR) + thumbnailBookRepository.findAllByBookIdAndType(thumbnail.bookId, ThumbnailBook.Type.SIDECAR) .filter { it.url == thumbnail.url } .forEach { thumbnailBookRepository.delete(it.id) @@ -86,11 +86,11 @@ class BookLifecycle( } fun getThumbnail(bookId: String): ThumbnailBook? { - val selected = thumbnailBookRepository.findSelectedByBookId(bookId) + val selected = thumbnailBookRepository.findSelectedByBookIdOrNull(bookId) if (selected == null || !selected.exists()) { thumbnailsHouseKeeping(bookId) - return thumbnailBookRepository.findSelectedByBookId(bookId) + return thumbnailBookRepository.findSelectedByBookIdOrNull(bookId) } return selected @@ -109,7 +109,7 @@ class BookLifecycle( private fun thumbnailsHouseKeeping(bookId: String) { logger.info { "House keeping thumbnails for book: $bookId" } - val all = thumbnailBookRepository.findByBookId(bookId) + val all = thumbnailBookRepository.findAllByBookId(bookId) .mapNotNull { if (!it.exists()) { logger.warn { "Thumbnail doesn't exist, removing entry" } @@ -204,13 +204,13 @@ class BookLifecycle( logger.info { "Delete all books: $bookIds" } readProgressRepository.deleteByBookIds(bookIds) - readListRepository.removeBookFromAll(bookIds) + readListRepository.removeBooksFromAll(bookIds) mediaRepository.deleteByBookIds(bookIds) thumbnailBookRepository.deleteByBookIds(bookIds) - bookMetadataRepository.deleteByBookIds(bookIds) + bookMetadataRepository.delete(bookIds) - bookRepository.deleteByBookIds(bookIds) + bookRepository.delete(bookIds) } fun markReadProgress(book: Book, user: KomgaUser, page: Int) { diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryContentLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryContentLifecycle.kt index 957ce7ac8..0e10d5937 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryContentLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryContentLifecycle.kt @@ -48,11 +48,11 @@ class LibraryContentLifecycle( // delete series that don't exist anymore if (scannedSeries.isEmpty()) { logger.info { "Scan returned no series, deleting all existing series" } - val seriesIds = seriesRepository.findByLibraryId(library.id).map { it.id } + val seriesIds = seriesRepository.findAllByLibraryId(library.id).map { it.id } seriesLifecycle.deleteMany(seriesIds) } else { scannedSeries.keys.map { it.url }.let { urls -> - val series = seriesRepository.findByLibraryIdAndUrlNotIn(library.id, urls) + val series = seriesRepository.findAllByLibraryIdAndUrlNotIn(library.id, urls) if (series.isNotEmpty()) { logger.info { "Deleting series not on disk anymore: $series" } seriesLifecycle.deleteMany(series.map { it.id }) @@ -61,7 +61,7 @@ class LibraryContentLifecycle( } scannedSeries.forEach { (newSeries, newBooks) -> - val existingSeries = seriesRepository.findByLibraryIdAndUrl(library.id, newSeries.url) + val existingSeries = seriesRepository.findByLibraryIdAndUrlOrNull(library.id, newSeries.url) // if series does not exist, save it if (existingSeries == null) { @@ -82,7 +82,7 @@ class LibraryContentLifecycle( } if (library.scanDeep || seriesChanged) { // update list of books with existing entities if they exist - val existingBooks = bookRepository.findBySeriesId(existingSeries.id) + val existingBooks = bookRepository.findAllBySeriesId(existingSeries.id) logger.debug { "Existing books: $existingBooks" } // update existing books newBooks.forEach { newBook -> @@ -134,7 +134,7 @@ class LibraryContentLifecycle( if (existingSidecar == null || existingSidecar.lastModifiedTime.isBefore(newSidecar.lastModifiedTime)) { when (newSidecar.source) { Sidecar.Source.SERIES -> - seriesRepository.findByLibraryIdAndUrl(library.id, newSidecar.parentUrl)?.let { series -> + seriesRepository.findByLibraryIdAndUrlOrNull(library.id, newSidecar.parentUrl)?.let { series -> when (newSidecar.type) { Sidecar.Type.ARTWORK -> taskReceiver.refreshSeriesLocalArtwork(series.id) } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt index 1ead41083..6ff93336b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/LibraryLifecycle.kt @@ -71,7 +71,7 @@ class LibraryLifecycle( fun deleteLibrary(library: Library) { logger.info { "Deleting library: $library" } - val seriesIds = seriesRepository.findByLibraryId(library.id).map { it.id } + val seriesIds = seriesRepository.findAllByLibraryId(library.id).map { it.id } seriesLifecycle.deleteMany(seriesIds) libraryRepository.delete(library.id) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataLifecycle.kt index 943d41951..39ebc6d64 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/MetadataLifecycle.kt @@ -143,7 +143,7 @@ class MetadataLifecycle( provider is EpubMetadataProvider && !library.importEpubSeries -> logger.info { "Library is not set to import series metadata from Epub, skipping" } else -> { logger.debug { "Provider: $provider" } - val patches = bookRepository.findBySeriesId(series.id) + val patches = bookRepository.findAllBySeriesId(series.id) .mapNotNull { provider.getSeriesMetadataFromBook(BookWithMedia(it, mediaRepository.findById(it.id))) } if ( @@ -220,7 +220,7 @@ class MetadataLifecycle( fun aggregateMetadata(series: Series) { logger.info { "Aggregate book metadata for series: $series" } - val metadatas = bookMetadataRepository.findByIds(bookRepository.findAllIdBySeriesId(series.id)) + val metadatas = bookMetadataRepository.findAllByIds(bookRepository.findAllIdsBySeriesId(series.id)) val aggregation = metadataAggregator.aggregate(metadatas).copy(seriesId = series.id) bookMetadataAggregationRepository.update(aggregation) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListMatcher.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListMatcher.kt index 5a5bd2bbd..8febcfe8e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListMatcher.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/ReadListMatcher.kt @@ -32,14 +32,14 @@ class ReadListMatcher( val unmatchedBooks = mutableListOf() request.books.forEach { book -> - val seriesMatches = seriesRepository.findByTitle(book.series) + val seriesMatches = seriesRepository.findAllByTitle(book.series) when { seriesMatches.size > 1 -> unmatchedBooks += ReadListRequestResultBook(book, "ERR_1011") seriesMatches.isEmpty() -> unmatchedBooks += ReadListRequestResultBook(book, "ERR_1012") else -> { val seriesId = seriesMatches.first().id - val seriesBooks = bookRepository.findBySeriesId(seriesId) - val bookMatches = bookMetadataRepository.findByIds(seriesBooks.map { it.id }) + val seriesBooks = bookRepository.findAllBySeriesId(seriesId) + val bookMatches = bookMetadataRepository.findAllByIds(seriesBooks.map { it.id }) .filter { (it.number.trimStart('0') == book.number.trimStart('0')) } .map { it.bookId } when { diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesLifecycle.kt index b724a45f6..5bfa9c3a4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/SeriesLifecycle.kt @@ -49,8 +49,8 @@ class SeriesLifecycle( fun sortBooks(series: Series) { logger.debug { "Sorting books for $series" } - val books = bookRepository.findBySeriesId(series.id) - val metadatas = bookMetadataRepository.findByIds(books.map { it.id }) + val books = bookRepository.findAllBySeriesId(series.id) + val metadatas = bookMetadataRepository.findAllByIds(books.map { it.id }) logger.debug { "Existing books: $books" } logger.debug { "Existing metadata: $metadatas" } @@ -59,7 +59,7 @@ class SeriesLifecycle( .map { book -> book to metadatas.first { it.bookId == book.id } } logger.debug { "Sorted books: $sorted" } - bookRepository.updateMany( + bookRepository.update( sorted.mapIndexed { index, (book, _) -> book.copy(number = index + 1) } ) @@ -70,7 +70,7 @@ class SeriesLifecycle( numberSort = if (!metadata.numberSortLock) (index + 1).toFloat() else metadata.numberSort ) } - bookMetadataRepository.updateMany(oldToNew.map { it.second }) + bookMetadataRepository.update(oldToNew.map { it.second }) // refresh metadata to reimport book number, else the series resorting would overwrite it oldToNew.forEach { (old, new) -> @@ -91,12 +91,12 @@ class SeriesLifecycle( check(it.libraryId == series.libraryId) { "Cannot add book to series if they don't share the same libraryId" } } - bookRepository.insertMany( + bookRepository.insert( booksToAdd.map { it.copy(seriesId = series.id) } ) // create associated media - mediaRepository.insertMany(booksToAdd.map { Media(bookId = it.id) }) + mediaRepository.insert(booksToAdd.map { Media(bookId = it.id) }) // create associated metadata booksToAdd.map { @@ -106,7 +106,7 @@ class SeriesLifecycle( numberSort = it.number.toFloat(), bookId = it.id ) - }.let { bookMetadataRepository.insertMany(it) } + }.let { bookMetadataRepository.insert(it) } } fun createSeries(series: Series): Series { @@ -130,7 +130,7 @@ class SeriesLifecycle( fun deleteOne(seriesId: String) { logger.info { "Delete series id: $seriesId" } - val bookIds = bookRepository.findAllIdBySeriesId(seriesId) + val bookIds = bookRepository.findAllIdsBySeriesId(seriesId) bookLifecycle.deleteMany(bookIds) collectionRepository.removeSeriesFromAll(seriesId) @@ -144,7 +144,7 @@ class SeriesLifecycle( fun deleteMany(seriesIds: Collection) { logger.info { "Delete series ids: $seriesIds" } - val bookIds = bookRepository.findAllIdBySeriesIds(seriesIds) + val bookIds = bookRepository.findAllIdsBySeriesIds(seriesIds) bookLifecycle.deleteMany(bookIds) collectionRepository.removeSeriesFromAll(seriesIds) @@ -152,26 +152,26 @@ class SeriesLifecycle( seriesMetadataRepository.delete(seriesIds) bookMetadataAggregationRepository.delete(seriesIds) - seriesRepository.deleteAll(seriesIds) + seriesRepository.delete(seriesIds) } fun markReadProgressCompleted(seriesId: String, user: KomgaUser) { - val progresses = mediaRepository.getPagesSizes(bookRepository.findAllIdBySeriesId(seriesId)) + val progresses = mediaRepository.getPagesSizes(bookRepository.findAllIdsBySeriesId(seriesId)) .map { (bookId, pageSize) -> ReadProgress(bookId, user.id, pageSize, true) } - readProgressRepository.saveAll(progresses) + readProgressRepository.save(progresses) } fun deleteReadProgress(seriesId: String, user: KomgaUser) { - readProgressRepository.deleteByBookIdsAndUserId(bookRepository.findAllIdBySeriesId(seriesId), user.id) + readProgressRepository.deleteByBookIdsAndUserId(bookRepository.findAllIdsBySeriesId(seriesId), user.id) } fun getThumbnail(seriesId: String): ThumbnailSeries? { - val selected = thumbnailsSeriesRepository.findSelectedBySeriesId(seriesId) + val selected = thumbnailsSeriesRepository.findSelectedBySeriesIdOrNull(seriesId) if (selected == null || !selected.exists()) { thumbnailsHouseKeeping(seriesId) - return thumbnailsSeriesRepository.findSelectedBySeriesId(seriesId) + return thumbnailsSeriesRepository.findSelectedBySeriesIdOrNull(seriesId) } return selected @@ -182,7 +182,7 @@ class SeriesLifecycle( return File(it.url.toURI()).readBytes() } - bookRepository.findFirstIdInSeries(seriesId)?.let { bookId -> + bookRepository.findFirstIdInSeriesOrNull(seriesId)?.let { bookId -> return bookLifecycle.getThumbnailBytes(bookId) } return null @@ -190,7 +190,7 @@ class SeriesLifecycle( fun addThumbnailForSeries(thumbnail: ThumbnailSeries) { // delete existing thumbnail with the same url - thumbnailsSeriesRepository.findBySeriesId(thumbnail.seriesId) + thumbnailsSeriesRepository.findAllBySeriesId(thumbnail.seriesId) .filter { it.url == thumbnail.url } .forEach { thumbnailsSeriesRepository.delete(it.id) @@ -203,7 +203,7 @@ class SeriesLifecycle( private fun thumbnailsHouseKeeping(seriesId: String) { logger.info { "House keeping thumbnails for series: $seriesId" } - val all = thumbnailsSeriesRepository.findBySeriesId(seriesId) + val all = thumbnailsSeriesRepository.findAllBySeriesId(seriesId) .mapNotNull { if (!it.exists()) { logger.warn { "Thumbnail doesn't exist, removing entry" } diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/TransientBookLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/TransientBookLifecycle.kt index df2863628..eacf5669c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/TransientBookLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/TransientBookLifecycle.kt @@ -27,7 +27,7 @@ class TransientBookLifecycle( val books = fileSystemScanner.scanRootFolder(folderToScan).series.values.flatten().map { BookWithMedia(it, Media()) } - transientBookRepository.saveAll(books) + transientBookRepository.save(books) return books } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/cache/TransientBookCache.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/cache/TransientBookCache.kt index 9eac7da77..de2808018 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/cache/TransientBookCache.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/cache/TransientBookCache.kt @@ -15,13 +15,13 @@ class TransientBookCache : TransientBookRepository { .expireAfterAccess(1, TimeUnit.HOURS) .build() - override fun findById(transientBookId: String): BookWithMedia? = cache.getIfPresent(transientBookId) + override fun findByIdOrNull(transientBookId: String): BookWithMedia? = cache.getIfPresent(transientBookId) override fun save(transientBook: BookWithMedia) { cache.put(transientBook.book.id, transientBook) } - override fun saveAll(transientBooks: Collection) { + override fun save(transientBooks: Collection) { cache.putAll(transientBooks.associateBy { it.book.id }) } } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt index 3825f3eda..60d83d5f4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDao.kt @@ -48,7 +48,7 @@ class BookDao( .fetchOneInto(b) ?.toDomain() - override fun findBySeriesId(seriesId: String): Collection = + override fun findAllBySeriesId(seriesId: String): Collection = dsl.selectFrom(b) .where(b.SERIES_ID.eq(seriesId)) .fetchInto(b) @@ -100,13 +100,13 @@ class BookDao( ) } - override fun getLibraryId(bookId: String): String? = + override fun getLibraryIdOrNull(bookId: String): String? = dsl.select(b.LIBRARY_ID) .from(b) .where(b.ID.eq(bookId)) .fetchOne(b.LIBRARY_ID) - override fun findFirstIdInSeries(seriesId: String): String? = + override fun findFirstIdInSeriesOrNull(seriesId: String): String? = dsl.select(b.ID) .from(b) .leftJoin(d).on(b.ID.eq(d.BOOK_ID)) @@ -115,25 +115,25 @@ class BookDao( .limit(1) .fetchOne(b.ID) - override fun findAllIdBySeriesId(seriesId: String): Collection = + override fun findAllIdsBySeriesId(seriesId: String): Collection = dsl.select(b.ID) .from(b) .where(b.SERIES_ID.eq(seriesId)) .fetch(b.ID) - override fun findAllIdBySeriesIds(seriesIds: Collection): Collection = + override fun findAllIdsBySeriesIds(seriesIds: Collection): Collection = dsl.select(b.ID) .from(b) .where(b.SERIES_ID.`in`(seriesIds)) .fetch(0, String::class.java) - override fun findAllIdByLibraryId(libraryId: String): Collection = + override fun findAllIdsByLibraryId(libraryId: String): Collection = dsl.select(b.ID) .from(b) .where(b.LIBRARY_ID.eq(libraryId)) .fetch(b.ID) - override fun findAllId(bookSearch: BookSearch, sort: Sort): Collection { + override fun findAllIds(bookSearch: BookSearch, sort: Sort): Collection { val conditions = bookSearch.toCondition() val orderBy = sort.toOrderBy(sorts) @@ -147,7 +147,7 @@ class BookDao( .fetch(b.ID) } - override fun findAllIdByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection): Collection = + override fun findAllIdsByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection): Collection = dsl.select(b.ID) .from(b) .leftJoin(m).on(b.ID.eq(m.BOOK_ID)) @@ -155,7 +155,7 @@ class BookDao( .and(m.MEDIA_TYPE.`in`(mediaTypes)) .fetch(b.ID) - override fun findAllIdByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection = + override fun findAllIdsByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection = dsl.select(b.ID) .from(b) .leftJoin(m).on(b.ID.eq(m.BOOK_ID)) @@ -165,10 +165,10 @@ class BookDao( .fetch(b.ID) override fun insert(book: Book) { - insertMany(listOf(book)) + insert(listOf(book)) } - override fun insertMany(books: Collection) { + override fun insert(books: Collection) { if (books.isNotEmpty()) { dsl.transaction { config -> config.dsl().batch( @@ -205,7 +205,7 @@ class BookDao( update(dsl, book) } - override fun updateMany(books: Collection) { + override fun update(books: Collection) { dsl.transaction { config -> books.map { update(config.dsl(), it) } } @@ -233,7 +233,7 @@ class BookDao( } } - override fun deleteByBookIds(bookIds: Collection) { + override fun delete(bookIds: Collection) { dsl.transaction { config -> with(config.dsl()) { deleteFrom(b).where(b.ID.`in`(bookIds)).execute() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt index f7acc311f..e5a574108 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDao.kt @@ -66,7 +66,7 @@ class BookDtoDao( return findAll(conditions, userId, pageable, search.toJoinConditions(), null) } - override fun findByReadListId( + override fun findAllByReadListId( readListId: String, userId: String, filterOnLibraryIds: Collection?, @@ -122,13 +122,13 @@ class BookDtoDao( .fetchAndMap() .firstOrNull() - override fun findPreviousInSeries(bookId: String, userId: String): BookDto? = + override fun findPreviousInSeriesOrNull(bookId: String, userId: String): BookDto? = findSiblingSeries(bookId, userId, next = false) - override fun findNextInSeries(bookId: String, userId: String): BookDto? = + override fun findNextInSeriesOrNull(bookId: String, userId: String): BookDto? = findSiblingSeries(bookId, userId, next = true) - override fun findPreviousInReadList( + override fun findPreviousInReadListOrNull( readListId: String, bookId: String, userId: String, @@ -136,7 +136,7 @@ class BookDtoDao( ): BookDto? = findSiblingReadList(readListId, bookId, userId, filterOnLibraryIds, next = false) - override fun findNextInReadList( + override fun findNextInReadListOrNull( readListId: String, bookId: String, userId: String, @@ -144,7 +144,7 @@ class BookDtoDao( ): BookDto? = findSiblingReadList(readListId, bookId, userId, filterOnLibraryIds, next = true) - override fun findOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { + override fun findAllOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { val seriesIds = dsl.select(s.ID) .from(s) .leftJoin(b).on(s.ID.eq(b.SERIES_ID)) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookMetadataDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookMetadataDao.kt index 9bc41b068..17dab5ec8 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookMetadataDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/BookMetadataDao.kt @@ -28,7 +28,7 @@ class BookMetadataDao( override fun findByIdOrNull(bookId: String): BookMetadata? = find(dsl, listOf(bookId)).firstOrNull() - override fun findByIds(bookIds: Collection): Collection = + override fun findAllByIds(bookIds: Collection): Collection = find(dsl, bookIds) private fun find(dsl: DSLContext, bookIds: Collection) = @@ -52,10 +52,10 @@ class BookMetadataDao( .toSet() override fun insert(metadata: BookMetadata) { - insertMany(listOf(metadata)) + insert(listOf(metadata)) } - override fun insertMany(metadatas: Collection) { + override fun insert(metadatas: Collection) { if (metadatas.isNotEmpty()) { dsl.transaction { config -> config.dsl().batch( @@ -111,7 +111,7 @@ class BookMetadataDao( } } - override fun updateMany(metadatas: Collection) { + override fun update(metadatas: Collection) { dsl.transaction { config -> metadatas.forEach { updateMetadata(config.dsl(), it) } } @@ -192,7 +192,7 @@ class BookMetadataDao( } } - override fun deleteByBookIds(bookIds: Collection) { + override fun delete(bookIds: Collection) { dsl.transaction { config -> with(config.dsl()) { deleteFrom(a).where(a.BOOK_ID.`in`(bookIds)).execute() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDao.kt index ad639ca55..ab263866b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDao.kt @@ -36,7 +36,7 @@ class LibraryDao( .fetchInto(l) .map { it.toDomain() } - override fun findAllById(libraryIds: Collection): Collection = + override fun findAllByIds(libraryIds: Collection): Collection = dsl.selectFrom(l) .where(l.ID.`in`(libraryIds)) .fetchInto(l) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/MediaDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/MediaDao.kt index 4ed0ad252..e996a86b4 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/MediaDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/MediaDao.kt @@ -59,10 +59,10 @@ class MediaDao( }.first() override fun insert(media: Media) { - insertMany(listOf(media)) + insert(listOf(media)) } - override fun insertMany(medias: Collection) { + override fun insert(medias: Collection) { if (medias.isNotEmpty()) { dsl.transaction { config -> config.dsl().batch( diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt index 73fe9a9a5..a94988475 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDao.kt @@ -44,7 +44,7 @@ class ReadListDao( .fetchAndMap(filterOnLibraryIds) .firstOrNull() - override fun findAll(search: String?, pageable: Pageable): Page { + override fun searchAll(search: String?, pageable: Pageable): Page { val conditions = search?.let { rl.NAME.containsIgnoreCase(it) } ?: DSL.trueCondition() @@ -70,7 +70,7 @@ class ReadListDao( ) } - override fun findAllByLibraries(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String?, pageable: Pageable): Page { + override fun findAllByLibraryIds(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String?, pageable: Pageable): Page { val ids = dsl.selectDistinct(rl.ID) .from(rl) .leftJoin(rlb).on(rl.ID.eq(rlb.READLIST_ID)) @@ -100,7 +100,7 @@ class ReadListDao( ) } - override fun findAllByBook(containsBookId: String, filterOnLibraryIds: Collection?): Collection { + override fun findAllContainingBookId(containsBookId: String, filterOnLibraryIds: Collection?): Collection { val ids = dsl.select(rl.ID) .from(rl) .leftJoin(rlb).on(rl.ID.eq(rlb.READLIST_ID)) @@ -185,7 +185,7 @@ class ReadListDao( .execute() } - override fun removeBookFromAll(bookIds: Collection) { + override fun removeBooksFromAll(bookIds: Collection) { dsl.deleteFrom(rlb) .where(rlb.BOOK_ID.`in`(bookIds)) .execute() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDao.kt index 71b7e2bbc..8b479a187 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDao.kt @@ -25,19 +25,19 @@ class ReadProgressDao( .fetchInto(r) .map { it.toDomain() } - override fun findByBookIdAndUserId(bookId: String, userId: String): ReadProgress? = + override fun findByBookIdAndUserIdOrNull(bookId: String, userId: String): ReadProgress? = dsl.selectFrom(r) .where(r.BOOK_ID.eq(bookId).and(r.USER_ID.eq(userId))) .fetchOneInto(r) ?.toDomain() - override fun findByUserId(userId: String): Collection = + override fun findAllByUserId(userId: String): Collection = dsl.selectFrom(r) .where(r.USER_ID.eq(userId)) .fetchInto(r) .map { it.toDomain() } - override fun findByBookId(bookId: String): Collection = + override fun findAllByBookId(bookId: String): Collection = dsl.selectFrom(r) .where(r.BOOK_ID.eq(bookId)) .fetchInto(r) @@ -50,7 +50,7 @@ class ReadProgressDao( } } - override fun saveAll(readProgresses: Collection) { + override fun save(readProgresses: Collection) { dsl.transaction { config -> val queries = readProgresses.map { config.dsl().saveQuery(it) } config.dsl().batch(queries).execute() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt index d416aa462..5bd92c406 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDtoDao.kt @@ -20,7 +20,7 @@ class ReadProgressDtoDao( private val d = Tables.BOOK_METADATA private val r = Tables.READ_PROGRESS - override fun getProgressBySeries(seriesId: String, userId: String): TachiyomiReadProgressDto { + override fun findProgressBySeries(seriesId: String, userId: String): TachiyomiReadProgressDto { val indexedReadProgress = dsl.select( rowNumber().over().orderBy(d.NUMBER_SORT), r.COMPLETED, @@ -46,7 +46,7 @@ class ReadProgressDtoDao( return booksCountToDto(booksCountRecord, indexedReadProgress) } - override fun getProgressByReadList(readListId: String, userId: String): TachiyomiReadProgressDto { + override fun findProgressByReadList(readListId: String, userId: String): TachiyomiReadProgressDto { val indexedReadProgress = dsl.select( rowNumber().over().orderBy(rlb.NUMBER), r.COMPLETED, diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt index c99660215..b32977813 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt @@ -32,7 +32,7 @@ class ReferentialDao( private val st = Tables.SERIES_METADATA_TAG private val cs = Tables.COLLECTION_SERIES - override fun findAuthorsByName(search: String, filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsByName(search: String, filterOnLibraryIds: Collection?): List = dsl.selectDistinct(a.NAME, a.ROLE) .from(a) .apply { filterOnLibraryIds?.let { leftJoin(b).on(a.BOOK_ID.eq(b.ID)) } } @@ -42,7 +42,7 @@ class ReferentialDao( .fetchInto(a) .map { it.toDomain() } - override fun findAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection?): List = dsl.selectDistinct(bmaa.NAME, bmaa.ROLE) .from(bmaa) .leftJoin(s).on(bmaa.SERIES_ID.eq(s.ID)) @@ -53,7 +53,7 @@ class ReferentialDao( .fetchInto(bmaa) .map { it.toDomain() } - override fun findAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection?): List = dsl.selectDistinct(bmaa.NAME, bmaa.ROLE) .from(bmaa) .leftJoin(cs).on(bmaa.SERIES_ID.eq(cs.SERIES_ID)) @@ -65,7 +65,7 @@ class ReferentialDao( .fetchInto(bmaa) .map { it.toDomain() } - override fun findAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection?): List = dsl.selectDistinct(bmaa.NAME, bmaa.ROLE) .from(bmaa) .apply { filterOnLibraryIds?.let { leftJoin(s).on(bmaa.SERIES_ID.eq(s.ID)) } } @@ -76,19 +76,19 @@ class ReferentialDao( .fetchInto(bmaa) .map { it.toDomain() } - override fun findAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection?, pageable: Pageable): Page { + override fun findAllAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection?, pageable: Pageable): Page { return findAuthorsByName(search, role, filterOnLibraryIds, pageable, null) } - override fun findAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { + override fun findAllAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.LIBRARY, libraryId)) } - override fun findAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { + override fun findAllAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.COLLECTION, collectionId)) } - override fun findAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { + override fun findAllAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page { return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.SERIES, seriesId)) } @@ -138,7 +138,7 @@ class ReferentialDao( ) } - override fun findAuthorsNamesByName(search: String, filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsNamesByName(search: String, filterOnLibraryIds: Collection?): List = dsl.selectDistinct(a.NAME) .from(a) .apply { filterOnLibraryIds?.let { leftJoin(b).on(a.BOOK_ID.eq(b.ID)) } } @@ -147,7 +147,7 @@ class ReferentialDao( .orderBy(a.NAME) .fetch(a.NAME) - override fun findAuthorsRoles(filterOnLibraryIds: Collection?): List = + override fun findAllAuthorsRoles(filterOnLibraryIds: Collection?): List = dsl.selectDistinct(a.ROLE) .from(a) .apply { diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDao.kt index bd361d9a1..72ed24683 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDao.kt @@ -43,7 +43,7 @@ class SeriesCollectionDao( .fetchAndMap(filterOnLibraryIds) .firstOrNull() - override fun findAll(search: String?, pageable: Pageable): Page { + override fun searchAll(search: String?, pageable: Pageable): Page { val conditions = search?.let { c.NAME.containsIgnoreCase(it) } ?: DSL.trueCondition() @@ -69,7 +69,7 @@ class SeriesCollectionDao( ) } - override fun findAllByLibraries(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String?, pageable: Pageable): Page { + override fun findAllByLibraryIds(belongsToLibraryIds: Collection, filterOnLibraryIds: Collection?, search: String?, pageable: Pageable): Page { val ids = dsl.selectDistinct(c.ID) .from(c) .leftJoin(cs).on(c.ID.eq(cs.COLLECTION_ID)) @@ -99,7 +99,7 @@ class SeriesCollectionDao( ) } - override fun findAllBySeries(containsSeriesId: String, filterOnLibraryIds: Collection?): Collection { + override fun findAllContainingSeriesId(containsSeriesId: String, filterOnLibraryIds: Collection?): Collection { val ids = dsl.select(c.ID) .from(c) .leftJoin(cs).on(c.ID.eq(cs.COLLECTION_ID)) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt index d28ce7ad3..99d40ef03 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDao.kt @@ -33,25 +33,25 @@ class SeriesDao( .fetchOneInto(s) ?.toDomain() - override fun findByLibraryId(libraryId: String): List = + override fun findAllByLibraryId(libraryId: String): List = dsl.selectFrom(s) .where(s.LIBRARY_ID.eq(libraryId)) .fetchInto(s) .map { it.toDomain() } - override fun findByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection): List = + override fun findAllByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection): List = dsl.selectFrom(s) .where(s.LIBRARY_ID.eq(libraryId).and(s.URL.notIn(urls.map { it.toString() }))) .fetchInto(s) .map { it.toDomain() } - override fun findByLibraryIdAndUrl(libraryId: String, url: URL): Series? = + override fun findByLibraryIdAndUrlOrNull(libraryId: String, url: URL): Series? = dsl.selectFrom(s) .where(s.LIBRARY_ID.eq(libraryId).and(s.URL.eq(url.toString()))) .fetchOneInto(s) ?.toDomain() - override fun findByTitle(title: String): Collection = + override fun findAllByTitle(title: String): Collection = dsl.selectDistinct(*s.fields()) .from(s) .leftJoin(d).on(s.ID.eq(d.SERIES_ID)) @@ -65,7 +65,7 @@ class SeriesDao( .where(s.ID.eq(seriesId)) .fetchOne(0, String::class.java) - override fun findAllIdByLibraryId(libraryId: String): Collection = + override fun findAllIdsByLibraryId(libraryId: String): Collection = dsl.select(s.ID) .from(s) .where(s.LIBRARY_ID.eq(libraryId)) @@ -121,7 +121,7 @@ class SeriesDao( } } - override fun deleteAll(seriesIds: Collection) { + override fun delete(seriesIds: Collection) { dsl.transaction { config -> with(config.dsl()) { deleteFrom(s).where(s.ID.`in`(seriesIds)).execute() diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt index c6521e6da..da6a8c376 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt @@ -79,7 +79,7 @@ class SeriesDtoDao( return findAll(conditions, userId, pageable, search.toJoinConditions()) } - override fun findByCollectionId( + override fun findAllByCollectionId( collectionId: String, search: SeriesSearchWithReadProgress, userId: String, @@ -91,7 +91,7 @@ class SeriesDtoDao( return findAll(conditions, userId, pageable, joinConditions) } - override fun findRecentlyUpdated( + override fun findAllRecentlyUpdated( search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailBookDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailBookDao.kt index fc53b3857..a94532efd 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailBookDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailBookDao.kt @@ -14,20 +14,20 @@ class ThumbnailBookDao( ) : ThumbnailBookRepository { private val tb = Tables.THUMBNAIL_BOOK - override fun findByBookId(bookId: String): Collection = + override fun findAllByBookId(bookId: String): Collection = dsl.selectFrom(tb) .where(tb.BOOK_ID.eq(bookId)) .fetchInto(tb) .map { it.toDomain() } - override fun findByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection = + override fun findAllByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection = dsl.selectFrom(tb) .where(tb.BOOK_ID.eq(bookId)) .and(tb.TYPE.eq(type.toString())) .fetchInto(tb) .map { it.toDomain() } - override fun findSelectedByBookId(bookId: String): ThumbnailBook? = + override fun findSelectedByBookIdOrNull(bookId: String): ThumbnailBook? = dsl.selectFrom(tb) .where(tb.BOOK_ID.eq(bookId)) .and(tb.SELECTED.isTrue) diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailSeriesDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailSeriesDao.kt index cb2d06909..769bd7b92 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailSeriesDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ThumbnailSeriesDao.kt @@ -14,13 +14,13 @@ class ThumbnailSeriesDao( ) : ThumbnailSeriesRepository { private val ts = Tables.THUMBNAIL_SERIES - override fun findBySeriesId(seriesId: String): Collection = + override fun findAllBySeriesId(seriesId: String): Collection = dsl.selectFrom(ts) .where(ts.SERIES_ID.eq(seriesId)) .fetchInto(ts) .map { it.toDomain() } - override fun findSelectedBySeriesId(seriesId: String): ThumbnailSeries? = + override fun findSelectedBySeriesIdOrNull(seriesId: String): ThumbnailSeries? = dsl.selectFrom(ts) .where(ts.SERIES_ID.eq(seriesId)) .and(ts.SELECTED.isTrue) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/opds/OpdsController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/opds/OpdsController.kt index 1635dc5b5..358193e91 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/opds/OpdsController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/opds/OpdsController.kt @@ -273,7 +273,7 @@ class OpdsController( if (principal.user.sharedAllLibraries) { libraryRepository.findAll() } else { - libraryRepository.findAllById(principal.user.sharedLibrariesIds) + libraryRepository.findAllByIds(principal.user.sharedLibrariesIds) } return OpdsFeedNavigation( id = ID_LIBRARIES_ALL, @@ -295,9 +295,9 @@ class OpdsController( val pageRequest = UnpagedSorted(Sort.by(Sort.Order.asc("name"))) val collections = if (principal.user.sharedAllLibraries) { - collectionRepository.findAll(pageable = pageRequest) + collectionRepository.searchAll(pageable = pageRequest) } else { - collectionRepository.findAllByLibraries(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, pageable = pageRequest) + collectionRepository.findAllByLibraryIds(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, pageable = pageRequest) } return OpdsFeedNavigation( id = ID_COLLECTIONS_ALL, @@ -319,9 +319,9 @@ class OpdsController( val pageRequest = UnpagedSorted(Sort.by(Sort.Order.asc("name"))) val readLists = if (principal.user.sharedAllLibraries) { - readListRepository.findAll(pageable = pageRequest) + readListRepository.searchAll(pageable = pageRequest) } else { - readListRepository.findAllByLibraries(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, pageable = pageRequest) + readListRepository.findAllByLibraryIds(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, pageable = pageRequest) } return OpdsFeedNavigation( id = ID_READLISTS_ALL, diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt index 81461ddd2..f3290d71c 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/BookController.kt @@ -159,7 +159,7 @@ class BookController( @RequestParam(name = "library_id", required = false) libraryIds: List?, @Parameter(hidden = true) page: Pageable ): Page = - bookDtoRepository.findOnDeck( + bookDtoRepository.findAllOnDeck( principal.user.id, principal.user.getAuthorizedLibraryIds(libraryIds), page @@ -180,11 +180,11 @@ class BookController( @AuthenticationPrincipal principal: KomgaPrincipal, @PathVariable bookId: String ): BookDto { - bookRepository.getLibraryId(bookId)?.let { + bookRepository.getLibraryIdOrNull(bookId)?.let { if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) - return bookDtoRepository.findPreviousInSeries(bookId, principal.user.id) + return bookDtoRepository.findPreviousInSeriesOrNull(bookId, principal.user.id) ?.restrictUrl(!principal.user.roleAdmin) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) } @@ -194,11 +194,11 @@ class BookController( @AuthenticationPrincipal principal: KomgaPrincipal, @PathVariable bookId: String ): BookDto { - bookRepository.getLibraryId(bookId)?.let { + bookRepository.getLibraryIdOrNull(bookId)?.let { if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) - return bookDtoRepository.findNextInSeries(bookId, principal.user.id) + return bookDtoRepository.findNextInSeriesOrNull(bookId, principal.user.id) ?.restrictUrl(!principal.user.roleAdmin) ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) } @@ -208,11 +208,11 @@ class BookController( @AuthenticationPrincipal principal: KomgaPrincipal, @PathVariable(name = "bookId") bookId: String ): List { - bookRepository.getLibraryId(bookId)?.let { + bookRepository.getLibraryIdOrNull(bookId)?.let { if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) - return readListRepository.findAllByBook(bookId, principal.user.getAuthorizedLibraryIds(null)) + return readListRepository.findAllContainingBookId(bookId, principal.user.getAuthorizedLibraryIds(null)) .map { it.toDto() } } @@ -228,7 +228,7 @@ class BookController( @AuthenticationPrincipal principal: KomgaPrincipal, @PathVariable bookId: String ): ByteArray { - bookRepository.getLibraryId(bookId)?.let { + bookRepository.getLibraryIdOrNull(bookId)?.let { if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt index 91fdb364c..34c528eae 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/LibraryController.kt @@ -52,7 +52,7 @@ class LibraryController( if (principal.user.sharedAllLibraries) { libraryRepository.findAll() } else { - libraryRepository.findAllById(principal.user.sharedLibrariesIds) + libraryRepository.findAllByIds(principal.user.sharedLibrariesIds) }.sortedBy { it.name.toLowerCase() }.map { it.toDto(includeRoot = principal.user.roleAdmin) } @GetMapping("{libraryId}") @@ -152,7 +152,7 @@ class LibraryController( @PreAuthorize("hasRole('$ROLE_ADMIN')") @ResponseStatus(HttpStatus.ACCEPTED) fun analyze(@PathVariable libraryId: String) { - bookRepository.findAllIdByLibraryId(libraryId).forEach { + bookRepository.findAllIdsByLibraryId(libraryId).forEach { taskReceiver.analyzeBook(it, HIGH_PRIORITY) } } @@ -161,11 +161,11 @@ class LibraryController( @PreAuthorize("hasRole('$ROLE_ADMIN')") @ResponseStatus(HttpStatus.ACCEPTED) fun refreshMetadata(@PathVariable libraryId: String) { - bookRepository.findAllIdByLibraryId(libraryId).forEach { + bookRepository.findAllIdsByLibraryId(libraryId).forEach { taskReceiver.refreshBookMetadata(it, priority = HIGH_PRIORITY) taskReceiver.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY) } - seriesRepository.findAllIdByLibraryId(libraryId).forEach { + seriesRepository.findAllIdsByLibraryId(libraryId).forEach { taskReceiver.refreshSeriesLocalArtwork(it, priority = HIGH_PRIORITY) } } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReadListController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReadListController.kt index 015503c69..10da4a3fd 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReadListController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReadListController.kt @@ -82,23 +82,23 @@ class ReadListController( ) return when { - principal.user.sharedAllLibraries && libraryIds == null -> readListRepository.findAll( + principal.user.sharedAllLibraries && libraryIds == null -> readListRepository.searchAll( searchTerm, pageable = pageRequest ) - principal.user.sharedAllLibraries && libraryIds != null -> readListRepository.findAllByLibraries( + principal.user.sharedAllLibraries && libraryIds != null -> readListRepository.findAllByLibraryIds( libraryIds, null, searchTerm, pageable = pageRequest ) - !principal.user.sharedAllLibraries && libraryIds != null -> readListRepository.findAllByLibraries( + !principal.user.sharedAllLibraries && libraryIds != null -> readListRepository.findAllByLibraryIds( libraryIds, principal.user.sharedLibrariesIds, searchTerm, pageable = pageRequest ) - else -> readListRepository.findAllByLibraries( + else -> readListRepository.findAllByLibraryIds( principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, searchTerm, @@ -202,7 +202,7 @@ class ReadListController( sort ) - bookDtoRepository.findByReadListId( + bookDtoRepository.findAllByReadListId( readList.id, principal.user.id, principal.user.getAuthorizedLibraryIds(null), @@ -218,7 +218,7 @@ class ReadListController( @PathVariable bookId: String ): BookDto = readListRepository.findByIdOrNull(id, principal.user.getAuthorizedLibraryIds(null))?.let { - bookDtoRepository.findPreviousInReadList( + bookDtoRepository.findPreviousInReadListOrNull( id, bookId, principal.user.id, @@ -234,7 +234,7 @@ class ReadListController( @PathVariable bookId: String ): BookDto = readListRepository.findByIdOrNull(id, principal.user.getAuthorizedLibraryIds(null))?.let { - bookDtoRepository.findNextInReadList( + bookDtoRepository.findNextInReadListOrNull( id, bookId, principal.user.id, @@ -249,7 +249,7 @@ class ReadListController( @AuthenticationPrincipal principal: KomgaPrincipal ): TachiyomiReadProgressDto = readListRepository.findByIdOrNull(id, principal.user.getAuthorizedLibraryIds(null))?.let { readList -> - readProgressDtoRepository.getProgressByReadList(readList.id, principal.user.id) + readProgressDtoRepository.findProgressByReadList(readList.id, principal.user.id) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) @PutMapping("{id}/read-progress/tachiyomi") @@ -260,7 +260,7 @@ class ReadListController( @AuthenticationPrincipal principal: KomgaPrincipal ) { readListRepository.findByIdOrNull(id, principal.user.getAuthorizedLibraryIds(null))?.let { readList -> - bookDtoRepository.findByReadListId( + bookDtoRepository.findAllByReadListId( readList.id, principal.user.id, principal.user.getAuthorizedLibraryIds(null), diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt index c6208dbce..af057ebae 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt @@ -32,10 +32,10 @@ class ReferentialController( ): List = when { - libraryId != null -> referentialRepository.findAuthorsByNameAndLibrary(search, libraryId, principal.user.getAuthorizedLibraryIds(null)) - collectionId != null -> referentialRepository.findAuthorsByNameAndCollection(search, collectionId, principal.user.getAuthorizedLibraryIds(null)) - seriesId != null -> referentialRepository.findAuthorsByNameAndSeries(search, seriesId, principal.user.getAuthorizedLibraryIds(null)) - else -> referentialRepository.findAuthorsByName(search, principal.user.getAuthorizedLibraryIds(null)) + libraryId != null -> referentialRepository.findAllAuthorsByNameAndLibrary(search, libraryId, principal.user.getAuthorizedLibraryIds(null)) + collectionId != null -> referentialRepository.findAllAuthorsByNameAndCollection(search, collectionId, principal.user.getAuthorizedLibraryIds(null)) + seriesId != null -> referentialRepository.findAllAuthorsByNameAndSeries(search, seriesId, principal.user.getAuthorizedLibraryIds(null)) + else -> referentialRepository.findAllAuthorsByName(search, principal.user.getAuthorizedLibraryIds(null)) }.map { it.toDto() } @PageableWithoutSortAsQueryParam @@ -58,10 +58,10 @@ class ReferentialController( ) return when { - libraryId != null -> referentialRepository.findAuthorsByNameAndLibrary(search, role, libraryId, principal.user.getAuthorizedLibraryIds(null), pageRequest) - collectionId != null -> referentialRepository.findAuthorsByNameAndCollection(search, role, collectionId, principal.user.getAuthorizedLibraryIds(null), pageRequest) - seriesId != null -> referentialRepository.findAuthorsByNameAndSeries(search, role, seriesId, principal.user.getAuthorizedLibraryIds(null), pageRequest) - else -> referentialRepository.findAuthorsByName(search, role, principal.user.getAuthorizedLibraryIds(null), pageRequest) + libraryId != null -> referentialRepository.findAllAuthorsByNameAndLibrary(search, role, libraryId, principal.user.getAuthorizedLibraryIds(null), pageRequest) + collectionId != null -> referentialRepository.findAllAuthorsByNameAndCollection(search, role, collectionId, principal.user.getAuthorizedLibraryIds(null), pageRequest) + seriesId != null -> referentialRepository.findAllAuthorsByNameAndSeries(search, role, seriesId, principal.user.getAuthorizedLibraryIds(null), pageRequest) + else -> referentialRepository.findAllAuthorsByName(search, role, principal.user.getAuthorizedLibraryIds(null), pageRequest) }.map { it.toDto() } } @@ -70,13 +70,13 @@ class ReferentialController( @AuthenticationPrincipal principal: KomgaPrincipal, @RequestParam(name = "search", defaultValue = "") search: String ): List = - referentialRepository.findAuthorsNamesByName(search, principal.user.getAuthorizedLibraryIds(null)) + referentialRepository.findAllAuthorsNamesByName(search, principal.user.getAuthorizedLibraryIds(null)) @GetMapping("v1/authors/roles") fun getAuthorsRoles( @AuthenticationPrincipal principal: KomgaPrincipal, ): List = - referentialRepository.findAuthorsRoles(principal.user.getAuthorizedLibraryIds(null)) + referentialRepository.findAllAuthorsRoles(principal.user.getAuthorizedLibraryIds(null)) @GetMapping("v1/genres") fun getGenres( diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt index edd0d9be5..0bc1ccd5b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesCollectionController.kt @@ -78,10 +78,10 @@ class SeriesCollectionController( ) return when { - principal.user.sharedAllLibraries && libraryIds == null -> collectionRepository.findAll(searchTerm, pageable = pageRequest) - principal.user.sharedAllLibraries && libraryIds != null -> collectionRepository.findAllByLibraries(libraryIds, null, searchTerm, pageable = pageRequest) - !principal.user.sharedAllLibraries && libraryIds != null -> collectionRepository.findAllByLibraries(libraryIds, principal.user.sharedLibrariesIds, searchTerm, pageable = pageRequest) - else -> collectionRepository.findAllByLibraries(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, searchTerm, pageable = pageRequest) + principal.user.sharedAllLibraries && libraryIds == null -> collectionRepository.searchAll(searchTerm, pageable = pageRequest) + principal.user.sharedAllLibraries && libraryIds != null -> collectionRepository.findAllByLibraryIds(libraryIds, null, searchTerm, pageable = pageRequest) + !principal.user.sharedAllLibraries && libraryIds != null -> collectionRepository.findAllByLibraryIds(libraryIds, principal.user.sharedLibrariesIds, searchTerm, pageable = pageRequest) + else -> collectionRepository.findAllByLibraryIds(principal.user.sharedLibrariesIds, principal.user.sharedLibrariesIds, searchTerm, pageable = pageRequest) }.map { it.toDto() } } @@ -201,7 +201,7 @@ class SeriesCollectionController( authors = authors ) - seriesDtoRepository.findByCollectionId(collection.id, seriesSearch, principal.user.id, pageRequest) + seriesDtoRepository.findAllByCollectionId(collection.id, seriesSearch, principal.user.id, pageRequest) .map { it.restrictUrl(!principal.user.roleAdmin) } } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt index 20ff50b7e..0f99b0fa6 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt @@ -210,7 +210,7 @@ class SeriesController( sort ) - return seriesDtoRepository.findRecentlyUpdated( + return seriesDtoRepository.findAllRecentlyUpdated( SeriesSearchWithReadProgress(principal.user.getAuthorizedLibraryIds(libraryIds)), principal.user.id, pageRequest @@ -290,7 +290,7 @@ class SeriesController( if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) - return collectionRepository.findAllBySeries(seriesId, principal.user.getAuthorizedLibraryIds(null)) + return collectionRepository.findAllContainingSeriesId(seriesId, principal.user.getAuthorizedLibraryIds(null)) .map { it.toDto() } } @@ -298,7 +298,7 @@ class SeriesController( @PreAuthorize("hasRole('$ROLE_ADMIN')") @ResponseStatus(HttpStatus.ACCEPTED) fun analyze(@PathVariable seriesId: String) { - bookRepository.findAllIdBySeriesId(seriesId).forEach { + bookRepository.findAllIdsBySeriesId(seriesId).forEach { taskReceiver.analyzeBook(it, HIGH_PRIORITY) } } @@ -307,7 +307,7 @@ class SeriesController( @PreAuthorize("hasRole('$ROLE_ADMIN')") @ResponseStatus(HttpStatus.ACCEPTED) fun refreshMetadata(@PathVariable seriesId: String) { - bookRepository.findAllIdBySeriesId(seriesId).forEach { + bookRepository.findAllIdsBySeriesId(seriesId).forEach { taskReceiver.refreshBookMetadata(it, priority = HIGH_PRIORITY) taskReceiver.refreshBookLocalArtwork(it, priority = HIGH_PRIORITY) } @@ -388,7 +388,7 @@ class SeriesController( ): TachiyomiReadProgressDto = seriesRepository.getLibraryId(seriesId)?.let { if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) - return readProgressDtoRepository.getProgressBySeries(seriesId, principal.user.id) + return readProgressDtoRepository.findProgressBySeries(seriesId, principal.user.id) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) @PutMapping("{seriesId}/read-progress/tachiyomi") @@ -423,7 +423,7 @@ class SeriesController( if (!principal.user.canAccessLibrary(it)) throw ResponseStatusException(HttpStatus.FORBIDDEN) } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) - val books = bookRepository.findBySeriesId(seriesId) + val books = bookRepository.findAllBySeriesId(seriesId) val streamingResponse = StreamingResponseBody { responseStream: OutputStream -> ZipArchiveOutputStream(responseStream).use { zipStream -> diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/TransientBooksController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/TransientBooksController.kt index beb5a7928..8d8c0b13e 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/TransientBooksController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/TransientBooksController.kt @@ -50,7 +50,7 @@ class TransientBooksController( @PostMapping("{id}/analyze") fun analyze( @PathVariable id: String, - ): TransientBookDto = transientBookRepository.findById(id)?.let { + ): TransientBookDto = transientBookRepository.findByIdOrNull(id)?.let { transientBookLifecycle.analyzeAndPersist(it).toDto() } ?: throw ResponseStatusException(HttpStatus.NOT_FOUND) @@ -62,7 +62,7 @@ class TransientBooksController( @PathVariable id: String, @PathVariable pageNumber: Int, ): ResponseEntity = - transientBookRepository.findById(id)?.let { + transientBookRepository.findByIdOrNull(id)?.let { try { val pageContent = transientBookLifecycle.getBookPage(it, pageNumber) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/UserController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/UserController.kt index 3727d57ad..06177304b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/UserController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/UserController.kt @@ -118,7 +118,7 @@ class UserController( val updatedUser = user.copy( sharedAllLibraries = sharedLibrariesUpdateDto.all, sharedLibrariesIds = if (sharedLibrariesUpdateDto.all) emptySet() - else libraryRepository.findAllById(sharedLibrariesUpdateDto.libraryIds) + else libraryRepository.findAllByIds(sharedLibrariesUpdateDto.libraryIds) .map { it.id } .toSet() ) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt index 3762932ec..0a51dc056 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/BookDtoRepository.kt @@ -11,7 +11,7 @@ interface BookDtoRepository { /** * Find books that are part of a readlist, optionally filtered by library */ - fun findByReadListId( + fun findAllByReadListId( readListId: String, userId: String, filterOnLibraryIds: Collection?, @@ -20,22 +20,22 @@ interface BookDtoRepository { fun findByIdOrNull(bookId: String, userId: String): BookDto? - fun findPreviousInSeries(bookId: String, userId: String): BookDto? - fun findNextInSeries(bookId: String, userId: String): BookDto? + fun findPreviousInSeriesOrNull(bookId: String, userId: String): BookDto? + fun findNextInSeriesOrNull(bookId: String, userId: String): BookDto? - fun findPreviousInReadList( + fun findPreviousInReadListOrNull( readListId: String, bookId: String, userId: String, filterOnLibraryIds: Collection? ): BookDto? - fun findNextInReadList( + fun findNextInReadListOrNull( readListId: String, bookId: String, userId: String, filterOnLibraryIds: Collection? ): BookDto? - fun findOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page + fun findAllOnDeck(userId: String, filterOnLibraryIds: Collection?, pageable: Pageable): Page } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/ReadProgressDtoRepository.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/ReadProgressDtoRepository.kt index ac6721f9f..c2fd2c183 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/ReadProgressDtoRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/ReadProgressDtoRepository.kt @@ -3,6 +3,6 @@ package org.gotson.komga.interfaces.rest.persistence import org.gotson.komga.interfaces.rest.dto.TachiyomiReadProgressDto interface ReadProgressDtoRepository { - fun getProgressBySeries(seriesId: String, userId: String,): TachiyomiReadProgressDto - fun getProgressByReadList(readListId: String, userId: String,): TachiyomiReadProgressDto + fun findProgressBySeries(seriesId: String, userId: String,): TachiyomiReadProgressDto + fun findProgressByReadList(readListId: String, userId: String,): TachiyomiReadProgressDto } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt index 06fe6ad68..ae90cd91b 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/persistence/SeriesDtoRepository.kt @@ -6,8 +6,9 @@ import org.springframework.data.domain.Page import org.springframework.data.domain.Pageable interface SeriesDtoRepository { - fun findAll(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page - fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page - fun findRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page fun findByIdOrNull(seriesId: String, userId: String): SeriesDto? + + fun findAll(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page + fun findAllByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page + fun findAllRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page } diff --git a/komga/src/test/kotlin/org/gotson/komga/domain/service/BookImporterTest.kt b/komga/src/test/kotlin/org/gotson/komga/domain/service/BookImporterTest.kt index 0d88e144b..1b0d14e9b 100644 --- a/komga/src/test/kotlin/org/gotson/komga/domain/service/BookImporterTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/domain/service/BookImporterTest.kt @@ -182,7 +182,7 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.COPY) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(3) assertThat(books[0].id).isEqualTo(existingBooks[0].id) assertThat(books[2].id).isEqualTo(existingBooks[1].id) @@ -225,7 +225,7 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.MOVE, upgradeBookId = bookToUpgrade.id) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(3) assertThat(books[0].id).isEqualTo(otherBooks[0].id) assertThat(books[1].id).isEqualTo(otherBooks[1].id) @@ -277,7 +277,7 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.MOVE, upgradeBookId = bookToUpgrade.id) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(3) assertThat(books[0].id).isEqualTo(otherBooks[0].id) assertThat(books[1].id).isEqualTo(otherBooks[1].id) @@ -325,7 +325,7 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.COPY, destinationName = "2", upgradeBookId = bookToUpgrade.id) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(3) assertThat(books[0].id).isEqualTo(otherBooks[0].id) assertThat(books[1].id).isNotEqualTo(bookToUpgrade.id) @@ -373,10 +373,10 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.MOVE, upgradeBookId = bookToUpgrade.id) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(1) - val progress = readProgressRepository.findByBookId(books[0].id) + val progress = readProgressRepository.findAllByBookId(books[0].id) assertThat(progress).hasSize(2) with(progress.find { it.userId == user1.id }!!) { assertThat(completed).isTrue @@ -415,7 +415,7 @@ class BookImporterTest( bookImporter.importBook(sourceFile, series, CopyMode.MOVE, upgradeBookId = bookToUpgrade.id) // then - val books = bookRepository.findBySeriesId(series.id).sortedBy { it.number } + val books = bookRepository.findAllBySeriesId(series.id).sortedBy { it.number } assertThat(books).hasSize(1) with(readListRepository.findByIdOrNull(readList.id)!!) { diff --git a/komga/src/test/kotlin/org/gotson/komga/domain/service/SeriesLifecycleTest.kt b/komga/src/test/kotlin/org/gotson/komga/domain/service/SeriesLifecycleTest.kt index 575767ff0..86604d4d4 100644 --- a/komga/src/test/kotlin/org/gotson/komga/domain/service/SeriesLifecycleTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/domain/service/SeriesLifecycleTest.kt @@ -66,7 +66,7 @@ class SeriesLifecycleTest( assertThat(seriesRepository.count()).isEqualTo(1) assertThat(bookRepository.count()).isEqualTo(4) - val savedBooks = bookRepository.findBySeriesId(createdSeries.id).sortedBy { it.number } + val savedBooks = bookRepository.findAllBySeriesId(createdSeries.id).sortedBy { it.number } assertThat(savedBooks.map { it.name }).containsExactly("book 1", "book 002", "book 05", "book 6") assertThat(savedBooks.map { it.number }).containsExactly(1, 2, 3, 4) } @@ -87,7 +87,7 @@ class SeriesLifecycleTest( seriesLifecycle.sortBooks(createdSeries) // when - val book = bookRepository.findBySeriesId(createdSeries.id).first { it.name == "book 2" } + val book = bookRepository.findAllBySeriesId(createdSeries.id).first { it.name == "book 2" } bookLifecycle.deleteOne(book.id) seriesLifecycle.sortBooks(createdSeries) @@ -95,7 +95,7 @@ class SeriesLifecycleTest( assertThat(seriesRepository.count()).isEqualTo(1) assertThat(bookRepository.count()).isEqualTo(3) - val savedBooks = bookRepository.findBySeriesId(createdSeries.id).sortedBy { it.number } + val savedBooks = bookRepository.findAllBySeriesId(createdSeries.id).sortedBy { it.number } assertThat(savedBooks.map { it.name }).containsExactly("book 1", "book 3", "book 4") assertThat(savedBooks.map { it.number }).containsExactly(1, 2, 3) } @@ -124,7 +124,7 @@ class SeriesLifecycleTest( assertThat(seriesRepository.count()).isEqualTo(1) assertThat(bookRepository.count()).isEqualTo(5) - val savedBooks = bookRepository.findBySeriesId(createdSeries.id).sortedBy { it.number } + val savedBooks = bookRepository.findAllBySeriesId(createdSeries.id).sortedBy { it.number } assertThat(savedBooks.map { it.name }).containsExactly("book 1", "book 2", "book 3", "book 4", "book 5") assertThat(savedBooks.map { it.number }).containsExactly(1, 2, 3, 4, 5) } diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDaoTest.kt index 79b8a5d56..94eba3e4f 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDaoTest.kt @@ -164,7 +164,7 @@ class BookDaoTest( bookDao.insert(makeBook("1", libraryId = library.id, seriesId = series.id)) bookDao.insert(makeBook("2", libraryId = library.id, seriesId = series.id)) - val found = bookDao.findAllIdByLibraryId(library.id) + val found = bookDao.findAllIdsByLibraryId(library.id) assertThat(found).hasSize(2) } @@ -174,7 +174,7 @@ class BookDaoTest( bookDao.insert(makeBook("1", libraryId = library.id, seriesId = series.id)) bookDao.insert(makeBook("2", libraryId = library.id, seriesId = series.id)) - val found = bookDao.findAllIdBySeriesId(series.id) + val found = bookDao.findAllIdsBySeriesId(series.id) assertThat(found).hasSize(2) } diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt index 2d23fcd95..75adcaf58 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/BookDtoDaoTest.kt @@ -230,7 +230,7 @@ class BookDtoDaoTest( setupBooks() // when - val found = bookDtoDao.findOnDeck( + val found = bookDtoDao.findAllOnDeck( user.id, null, PageRequest.of(0, 20) @@ -251,7 +251,7 @@ class BookDtoDaoTest( ) // when - val found = bookDtoDao.findOnDeck( + val found = bookDtoDao.findAllOnDeck( user.id, null, PageRequest.of(0, 20) @@ -275,7 +275,7 @@ class BookDtoDaoTest( books.elementAt(0).let { readProgressRepository.save(ReadProgress(it.id, user.id, 5, true)) } // when - val found = bookDtoDao.findOnDeck( + val found = bookDtoDao.findAllOnDeck( user.id, null, PageRequest.of(0, 20) diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDaoTest.kt index 8e36e58a8..2e6310334 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/LibraryDaoTest.kt @@ -160,7 +160,7 @@ class LibraryDaoTest( libraryDao.insert(library) libraryDao.insert(library2) - val all = libraryDao.findAllById(listOf(library.id, library2.id)) + val all = libraryDao.findAllByIds(listOf(library.id, library2.id)) assertThat(all).hasSize(2) assertThat(all.map { it.name }).containsExactlyInAnyOrder("Library", "Library2") diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDaoTest.kt index caa0af784..d5c2a0dc7 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadListDaoTest.kt @@ -176,11 +176,11 @@ class ReadListDaoTest( ) // when - val foundLibrary1Filtered = readListDao.findAllByLibraries(listOf(library.id), listOf(library.id), pageable = Pageable.unpaged()).content - val foundLibrary1Unfiltered = readListDao.findAllByLibraries(listOf(library.id), null, pageable = Pageable.unpaged()).content - val foundLibrary2Filtered = readListDao.findAllByLibraries(listOf(library2.id), listOf(library2.id), pageable = Pageable.unpaged()).content - val foundLibrary2Unfiltered = readListDao.findAllByLibraries(listOf(library2.id), null, pageable = Pageable.unpaged()).content - val foundBothUnfiltered = readListDao.findAllByLibraries(listOf(library.id, library2.id), null, pageable = Pageable.unpaged()).content + val foundLibrary1Filtered = readListDao.findAllByLibraryIds(listOf(library.id), listOf(library.id), pageable = Pageable.unpaged()).content + val foundLibrary1Unfiltered = readListDao.findAllByLibraryIds(listOf(library.id), null, pageable = Pageable.unpaged()).content + val foundLibrary2Filtered = readListDao.findAllByLibraryIds(listOf(library2.id), listOf(library2.id), pageable = Pageable.unpaged()).content + val foundLibrary2Unfiltered = readListDao.findAllByLibraryIds(listOf(library2.id), null, pageable = Pageable.unpaged()).content + val foundBothUnfiltered = readListDao.findAllByLibraryIds(listOf(library.id, library2.id), null, pageable = Pageable.unpaged()).content // then assertThat(foundLibrary1Filtered).hasSize(2) diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDaoTest.kt index 4eea788dc..8a80f22d2 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/ReadProgressDaoTest.kt @@ -74,7 +74,7 @@ class ReadProgressDaoTest( ) ) - val readProgressList = readProgressDao.findByUserId(user1.id) + val readProgressList = readProgressDao.findAllByUserId(user1.id) assertThat(readProgressList).hasSize(1) with(readProgressList.first()) { @@ -109,7 +109,7 @@ class ReadProgressDaoTest( ) ) - val readProgressList = readProgressDao.findByUserId(user1.id) + val readProgressList = readProgressDao.findAllByUserId(user1.id) assertThat(readProgressList).hasSize(1) with(readProgressList.first()) { diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDaoTest.kt index 71877f83e..2f0390a36 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesCollectionDaoTest.kt @@ -166,11 +166,11 @@ class SeriesCollectionDaoTest( ) // when - val foundLibrary1Filtered = collectionDao.findAllByLibraries(listOf(library.id), listOf(library.id), pageable = Pageable.unpaged()).content - val foundLibrary1Unfiltered = collectionDao.findAllByLibraries(listOf(library.id), null, pageable = Pageable.unpaged()).content - val foundLibrary2Filtered = collectionDao.findAllByLibraries(listOf(library2.id), listOf(library2.id), pageable = Pageable.unpaged()).content - val foundLibrary2Unfiltered = collectionDao.findAllByLibraries(listOf(library2.id), null, pageable = Pageable.unpaged()).content - val foundBothUnfiltered = collectionDao.findAllByLibraries(listOf(library.id, library2.id), null, pageable = Pageable.unpaged()).content + val foundLibrary1Filtered = collectionDao.findAllByLibraryIds(listOf(library.id), listOf(library.id), pageable = Pageable.unpaged()).content + val foundLibrary1Unfiltered = collectionDao.findAllByLibraryIds(listOf(library.id), null, pageable = Pageable.unpaged()).content + val foundLibrary2Filtered = collectionDao.findAllByLibraryIds(listOf(library2.id), listOf(library2.id), pageable = Pageable.unpaged()).content + val foundLibrary2Unfiltered = collectionDao.findAllByLibraryIds(listOf(library2.id), null, pageable = Pageable.unpaged()).content + val foundBothUnfiltered = collectionDao.findAllByLibraryIds(listOf(library.id, library2.id), null, pageable = Pageable.unpaged()).content // then assertThat(foundLibrary1Filtered).hasSize(2) diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDaoTest.kt index ff18da129..7d94ee51f 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDaoTest.kt @@ -184,7 +184,7 @@ class SeriesDaoTest( ) seriesDao.insert(series) - val found = seriesDao.findByLibraryId(library.id) + val found = seriesDao.findAllByLibraryId(library.id) assertThat(found).hasSize(1) assertThat(found.first().name).isEqualTo("Series") @@ -200,7 +200,7 @@ class SeriesDaoTest( ) seriesDao.insert(series) - val found = seriesDao.findByLibraryId(library.id + 1) + val found = seriesDao.findAllByLibraryId(library.id + 1) assertThat(found).hasSize(0) } @@ -215,8 +215,8 @@ class SeriesDaoTest( ) seriesDao.insert(series) - val found = seriesDao.findByLibraryIdAndUrlNotIn(library.id, listOf(URL("file://series2"))) - val notFound = seriesDao.findByLibraryIdAndUrlNotIn(library.id, listOf(URL("file://series"))) + val found = seriesDao.findAllByLibraryIdAndUrlNotIn(library.id, listOf(URL("file://series2"))) + val notFound = seriesDao.findAllByLibraryIdAndUrlNotIn(library.id, listOf(URL("file://series"))) assertThat(found).hasSize(1) assertThat(found.first().name).isEqualTo("Series") @@ -234,10 +234,10 @@ class SeriesDaoTest( ) seriesDao.insert(series) - val found = seriesDao.findByLibraryIdAndUrl(library.id, URL("file://series")) - val notFound1 = seriesDao.findByLibraryIdAndUrl(library.id, URL("file://series2")) - val notFound2 = seriesDao.findByLibraryIdAndUrl(library.id + 1, URL("file://series")) - val notFound3 = seriesDao.findByLibraryIdAndUrl(library.id + 1, URL("file://series2")) + val found = seriesDao.findByLibraryIdAndUrlOrNull(library.id, URL("file://series")) + val notFound1 = seriesDao.findByLibraryIdAndUrlOrNull(library.id, URL("file://series2")) + val notFound2 = seriesDao.findByLibraryIdAndUrlOrNull(library.id + 1, URL("file://series")) + val notFound3 = seriesDao.findByLibraryIdAndUrlOrNull(library.id + 1, URL("file://series2")) assertThat(found).isNotNull assertThat(found?.name).isEqualTo("Series") diff --git a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDaoTest.kt b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDaoTest.kt index 7648e29fa..3bdffaf6f 100644 --- a/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDaoTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDaoTest.kt @@ -80,16 +80,16 @@ class SeriesDtoDaoTest( val series = seriesRepository.findAll().sortedBy { it.name } // series "1": only in progress books series.elementAt(0).let { - bookRepository.findBySeriesId(it.id).forEach { readProgressRepository.save(ReadProgress(it.id, user.id, 5, false)) } + bookRepository.findAllBySeriesId(it.id).forEach { readProgressRepository.save(ReadProgress(it.id, user.id, 5, false)) } } // series "2": only read books series.elementAt(1).let { - bookRepository.findBySeriesId(it.id).forEach { readProgressRepository.save(ReadProgress(it.id, user.id, 5, true)) } + bookRepository.findAllBySeriesId(it.id).forEach { readProgressRepository.save(ReadProgress(it.id, user.id, 5, true)) } } // series "3": only unread books // series "4": read, unread, and in progress series.elementAt(3).let { - val books = bookRepository.findBySeriesId(it.id).sortedBy { it.name } + val books = bookRepository.findAllBySeriesId(it.id).sortedBy { it.name } books.elementAt(0).let { readProgressRepository.save(ReadProgress(it.id, user.id, 5, false)) } books.elementAt(1).let { readProgressRepository.save(ReadProgress(it.id, user.id, 5, true)) } } diff --git a/komga/src/test/kotlin/org/gotson/komga/interfaces/rest/BookControllerTest.kt b/komga/src/test/kotlin/org/gotson/komga/interfaces/rest/BookControllerTest.kt index 92d168dd4..70fb9b2ab 100644 --- a/komga/src/test/kotlin/org/gotson/komga/interfaces/rest/BookControllerTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/interfaces/rest/BookControllerTest.kt @@ -360,7 +360,7 @@ class BookControllerTest( } } - val first = bookRepository.findFirstIdInSeries(series.id) + val first = bookRepository.findFirstIdInSeriesOrNull(series.id) val second = bookRepository.findAll(BookSearch(searchTerm = "2")).first().id val third = bookRepository.findAll(BookSearch(searchTerm = "3")).first().id