mirror of
https://github.com/gotson/komga.git
synced 2026-01-16 21:21:53 +01:00
refactor: harmonize repository method names
This commit is contained in:
parent
4244bcd9ae
commit
f49786a957
61 changed files with 280 additions and 268 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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<String>): Collection<BookMetadata>
|
||||
|
||||
fun findAllByIds(bookIds: Collection<String>): Collection<BookMetadata>
|
||||
|
||||
fun insert(metadata: BookMetadata)
|
||||
fun insertMany(metadatas: Collection<BookMetadata>)
|
||||
fun insert(metadatas: Collection<BookMetadata>)
|
||||
|
||||
fun update(metadata: BookMetadata)
|
||||
fun updateMany(metadatas: Collection<BookMetadata>)
|
||||
fun update(metadatas: Collection<BookMetadata>)
|
||||
|
||||
fun delete(bookId: String)
|
||||
fun deleteByBookIds(bookIds: Collection<String>)
|
||||
fun delete(bookIds: Collection<String>)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -11,28 +11,28 @@ interface BookRepository {
|
|||
fun findByIdOrNull(bookId: String): Book?
|
||||
fun findByLibraryIdAndUrlOrNull(libraryId: String, url: URL): Book?
|
||||
|
||||
fun findBySeriesId(seriesId: String): Collection<Book>
|
||||
fun findAll(): Collection<Book>
|
||||
fun findAllBySeriesId(seriesId: String): Collection<Book>
|
||||
fun findAll(bookSearch: BookSearch): Collection<Book>
|
||||
fun findAll(bookSearch: BookSearch, pageable: Pageable): Page<Book>
|
||||
|
||||
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<String>
|
||||
fun findAllIdBySeriesIds(seriesIds: Collection<String>): Collection<String>
|
||||
fun findAllIdByLibraryId(libraryId: String): Collection<String>
|
||||
fun findAllId(bookSearch: BookSearch, sort: Sort): Collection<String>
|
||||
fun findAllIdByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection<String>): Collection<String>
|
||||
fun findAllIdByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection<String>
|
||||
fun findAllIdsBySeriesId(seriesId: String): Collection<String>
|
||||
fun findAllIdsBySeriesIds(seriesIds: Collection<String>): Collection<String>
|
||||
fun findAllIdsByLibraryId(libraryId: String): Collection<String>
|
||||
fun findAllIdsByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection<String>): Collection<String>
|
||||
fun findAllIdsByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection<String>
|
||||
fun findAllIds(bookSearch: BookSearch, sort: Sort): Collection<String>
|
||||
|
||||
fun insert(book: Book)
|
||||
fun insertMany(books: Collection<Book>)
|
||||
fun insert(books: Collection<Book>)
|
||||
fun update(book: Book)
|
||||
fun updateMany(books: Collection<Book>)
|
||||
fun update(books: Collection<Book>)
|
||||
|
||||
fun delete(bookId: String)
|
||||
fun deleteByBookIds(bookIds: Collection<String>)
|
||||
fun delete(bookIds: Collection<String>)
|
||||
fun deleteAll()
|
||||
|
||||
fun count(): Long
|
||||
|
|
|
|||
|
|
@ -5,15 +5,16 @@ import org.gotson.komga.domain.model.KomgaUser
|
|||
interface KomgaUserRepository {
|
||||
fun count(): Long
|
||||
|
||||
fun findAll(): Collection<KomgaUser>
|
||||
fun findByIdOrNull(id: String): KomgaUser?
|
||||
fun findByEmailIgnoreCase(email: String): KomgaUser?
|
||||
|
||||
fun findAll(): Collection<KomgaUser>
|
||||
|
||||
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?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Library>
|
||||
fun findAllById(libraryIds: Collection<String>): Collection<Library>
|
||||
fun findAllByIds(libraryIds: Collection<String>): Collection<Library>
|
||||
|
||||
fun delete(libraryId: String)
|
||||
fun deleteAll()
|
||||
|
|
|
|||
|
|
@ -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<String>): Collection<Pair<String, Int>>
|
||||
|
||||
fun insert(media: Media)
|
||||
fun insertMany(medias: Collection<Media>)
|
||||
fun insert(medias: Collection<Media>)
|
||||
|
||||
fun update(media: Media)
|
||||
|
||||
fun delete(bookId: String)
|
||||
|
|
|
|||
|
|
@ -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<ReadList>
|
||||
|
||||
fun searchAll(search: String? = null, pageable: Pageable): Page<ReadList>
|
||||
|
||||
/**
|
||||
* 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<String>, filterOnLibraryIds: Collection<String>?, search: String? = null, pageable: Pageable): Page<ReadList>
|
||||
fun findAllByLibraryIds(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String? = null, pageable: Pageable): Page<ReadList>
|
||||
|
||||
/**
|
||||
* Find all ReadList that contains the provided containsBookId,
|
||||
* optionally with only bookIds filtered by the provided filterOnLibraryIds.
|
||||
*/
|
||||
fun findAllByBook(containsBookId: String, filterOnLibraryIds: Collection<String>?): Collection<ReadList>
|
||||
fun findAllContainingBookId(containsBookId: String, filterOnLibraryIds: Collection<String>?): Collection<ReadList>
|
||||
|
||||
fun findByNameOrNull(name: String): ReadList?
|
||||
|
||||
|
|
@ -32,11 +33,11 @@ interface ReadListRepository {
|
|||
fun update(readList: ReadList)
|
||||
|
||||
fun removeBookFromAll(bookId: String)
|
||||
fun removeBookFromAll(bookIds: Collection<String>)
|
||||
fun removeBooksFromAll(bookIds: Collection<String>)
|
||||
|
||||
fun delete(readListId: String)
|
||||
|
||||
fun deleteAll()
|
||||
fun deleteEmpty()
|
||||
|
||||
fun existsByName(name: String): Boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<ReadProgress>
|
||||
fun findByBookIdAndUserId(bookId: String, userId: String): ReadProgress?
|
||||
fun findByUserId(userId: String): Collection<ReadProgress>
|
||||
fun findByBookId(bookId: String): Collection<ReadProgress>
|
||||
fun findAllByUserId(userId: String): Collection<ReadProgress>
|
||||
fun findAllByBookId(bookId: String): Collection<ReadProgress>
|
||||
|
||||
fun save(readProgress: ReadProgress)
|
||||
fun saveAll(readProgresses: Collection<ReadProgress>)
|
||||
fun save(readProgresses: Collection<ReadProgress>)
|
||||
|
||||
fun delete(bookId: String, userId: String)
|
||||
fun deleteByUserId(userId: String)
|
||||
|
|
|
|||
|
|
@ -6,17 +6,17 @@ import org.springframework.data.domain.Pageable
|
|||
import java.time.LocalDate
|
||||
|
||||
interface ReferentialRepository {
|
||||
fun findAuthorsByName(search: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAuthorsNamesByName(search: String, filterOnLibraryIds: Collection<String>?): List<String>
|
||||
fun findAuthorsRoles(filterOnLibraryIds: Collection<String>?): List<String>
|
||||
fun findAllAuthorsByName(search: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAllAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAllAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAllAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection<String>?): List<Author>
|
||||
fun findAllAuthorsNamesByName(search: String, filterOnLibraryIds: Collection<String>?): List<String>
|
||||
fun findAllAuthorsRoles(filterOnLibraryIds: Collection<String>?): List<String>
|
||||
|
||||
fun findAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAllAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAllAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAllAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
fun findAllAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author>
|
||||
|
||||
fun findAllGenres(filterOnLibraryIds: Collection<String>?): Set<String>
|
||||
fun findAllGenresByLibrary(libraryId: String, filterOnLibraryIds: Collection<String>?): Set<String>
|
||||
|
|
|
|||
|
|
@ -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<SeriesCollection>
|
||||
|
||||
fun searchAll(search: String? = null, pageable: Pageable): Page<SeriesCollection>
|
||||
|
||||
/**
|
||||
* 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<String>, filterOnLibraryIds: Collection<String>?, search: String? = null, pageable: Pageable): Page<SeriesCollection>
|
||||
fun findAllByLibraryIds(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String? = null, pageable: Pageable): Page<SeriesCollection>
|
||||
|
||||
/**
|
||||
* Find all SeriesCollection that contains the provided containsSeriesId,
|
||||
* optionally with only seriesId filtered by the provided filterOnLibraryIds.
|
||||
*/
|
||||
fun findAllBySeries(containsSeriesId: String, filterOnLibraryIds: Collection<String>?): Collection<SeriesCollection>
|
||||
fun findAllContainingSeriesId(containsSeriesId: String, filterOnLibraryIds: Collection<String>?): Collection<SeriesCollection>
|
||||
|
||||
fun findByNameOrNull(name: String): SeriesCollection?
|
||||
|
||||
|
|
@ -35,8 +36,8 @@ interface SeriesCollectionRepository {
|
|||
fun removeSeriesFromAll(seriesIds: Collection<String>)
|
||||
|
||||
fun delete(collectionId: String)
|
||||
|
||||
fun deleteAll()
|
||||
fun deleteEmpty()
|
||||
|
||||
fun existsByName(name: String): Boolean
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Series>
|
||||
fun findByLibraryId(libraryId: String): Collection<Series>
|
||||
fun findByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection<URL>): Collection<Series>
|
||||
fun findAllByLibraryId(libraryId: String): Collection<Series>
|
||||
fun findAllByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection<URL>): Collection<Series>
|
||||
fun findAllByTitle(title: String): Collection<Series>
|
||||
fun findAll(search: SeriesSearch): Collection<Series>
|
||||
fun findByTitle(title: String): Collection<Series>
|
||||
|
||||
fun getLibraryId(seriesId: String): String?
|
||||
|
||||
fun findAllIdByLibraryId(libraryId: String): Collection<String>
|
||||
fun findAllIdsByLibraryId(libraryId: String): Collection<String>
|
||||
|
||||
fun insert(series: Series)
|
||||
fun update(series: Series)
|
||||
|
||||
fun delete(seriesId: String)
|
||||
fun delete(seriesIds: Collection<String>)
|
||||
fun deleteAll()
|
||||
fun deleteAll(seriesIds: Collection<String>)
|
||||
|
||||
fun count(): Long
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,9 +3,10 @@ package org.gotson.komga.domain.persistence
|
|||
import org.gotson.komga.domain.model.ThumbnailBook
|
||||
|
||||
interface ThumbnailBookRepository {
|
||||
fun findByBookId(bookId: String): Collection<ThumbnailBook>
|
||||
fun findByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection<ThumbnailBook>
|
||||
fun findSelectedByBookId(bookId: String): ThumbnailBook?
|
||||
fun findSelectedByBookIdOrNull(bookId: String): ThumbnailBook?
|
||||
|
||||
fun findAllByBookId(bookId: String): Collection<ThumbnailBook>
|
||||
fun findAllByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection<ThumbnailBook>
|
||||
|
||||
fun insert(thumbnail: ThumbnailBook)
|
||||
fun update(thumbnail: ThumbnailBook)
|
||||
|
|
|
|||
|
|
@ -3,8 +3,9 @@ package org.gotson.komga.domain.persistence
|
|||
import org.gotson.komga.domain.model.ThumbnailSeries
|
||||
|
||||
interface ThumbnailSeriesRepository {
|
||||
fun findBySeriesId(seriesId: String): Collection<ThumbnailSeries>
|
||||
fun findSelectedBySeriesId(seriesId: String): ThumbnailSeries?
|
||||
fun findSelectedBySeriesIdOrNull(seriesId: String): ThumbnailSeries?
|
||||
|
||||
fun findAllBySeriesId(seriesId: String): Collection<ThumbnailSeries>
|
||||
|
||||
fun insert(thumbnail: ThumbnailSeries)
|
||||
fun markSelected(thumbnail: ThumbnailSeries)
|
||||
|
|
|
|||
|
|
@ -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<BookWithMedia>)
|
||||
fun save(transientBooks: Collection<BookWithMedia>)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ class BookConverter(
|
|||
private val skippedRepairs = mutableListOf<String>()
|
||||
|
||||
fun getConvertibleBookIds(library: Library): Collection<String> =
|
||||
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<String> =
|
||||
mediaTypeToExtension.flatMap { (mediaType, extension) ->
|
||||
bookRepository.findAllIdByLibraryIdAndMismatchedExtension(library.id, mediaType, extension)
|
||||
bookRepository.findAllIdsByLibraryIdAndMismatchedExtension(library.id, mediaType, extension)
|
||||
}
|
||||
|
||||
fun repairExtension(book: Book) {
|
||||
|
|
|
|||
|
|
@ -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(
|
||||
|
|
|
|||
|
|
@ -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) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -32,14 +32,14 @@ class ReadListMatcher(
|
|||
val unmatchedBooks = mutableListOf<ReadListRequestResultBook>()
|
||||
|
||||
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 {
|
||||
|
|
|
|||
|
|
@ -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<String>) {
|
||||
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" }
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -15,13 +15,13 @@ class TransientBookCache : TransientBookRepository {
|
|||
.expireAfterAccess(1, TimeUnit.HOURS)
|
||||
.build<String, BookWithMedia>()
|
||||
|
||||
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<BookWithMedia>) {
|
||||
override fun save(transientBooks: Collection<BookWithMedia>) {
|
||||
cache.putAll(transientBooks.associateBy { it.book.id })
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ class BookDao(
|
|||
.fetchOneInto(b)
|
||||
?.toDomain()
|
||||
|
||||
override fun findBySeriesId(seriesId: String): Collection<Book> =
|
||||
override fun findAllBySeriesId(seriesId: String): Collection<Book> =
|
||||
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<String> =
|
||||
override fun findAllIdsBySeriesId(seriesId: String): Collection<String> =
|
||||
dsl.select(b.ID)
|
||||
.from(b)
|
||||
.where(b.SERIES_ID.eq(seriesId))
|
||||
.fetch(b.ID)
|
||||
|
||||
override fun findAllIdBySeriesIds(seriesIds: Collection<String>): Collection<String> =
|
||||
override fun findAllIdsBySeriesIds(seriesIds: Collection<String>): Collection<String> =
|
||||
dsl.select(b.ID)
|
||||
.from(b)
|
||||
.where(b.SERIES_ID.`in`(seriesIds))
|
||||
.fetch(0, String::class.java)
|
||||
|
||||
override fun findAllIdByLibraryId(libraryId: String): Collection<String> =
|
||||
override fun findAllIdsByLibraryId(libraryId: String): Collection<String> =
|
||||
dsl.select(b.ID)
|
||||
.from(b)
|
||||
.where(b.LIBRARY_ID.eq(libraryId))
|
||||
.fetch(b.ID)
|
||||
|
||||
override fun findAllId(bookSearch: BookSearch, sort: Sort): Collection<String> {
|
||||
override fun findAllIds(bookSearch: BookSearch, sort: Sort): Collection<String> {
|
||||
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<String>): Collection<String> =
|
||||
override fun findAllIdsByLibraryIdAndMediaTypes(libraryId: String, mediaTypes: Collection<String>): Collection<String> =
|
||||
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<String> =
|
||||
override fun findAllIdsByLibraryIdAndMismatchedExtension(libraryId: String, mediaType: String, extension: String): Collection<String> =
|
||||
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<Book>) {
|
||||
override fun insert(books: Collection<Book>) {
|
||||
if (books.isNotEmpty()) {
|
||||
dsl.transaction { config ->
|
||||
config.dsl().batch(
|
||||
|
|
@ -205,7 +205,7 @@ class BookDao(
|
|||
update(dsl, book)
|
||||
}
|
||||
|
||||
override fun updateMany(books: Collection<Book>) {
|
||||
override fun update(books: Collection<Book>) {
|
||||
dsl.transaction { config ->
|
||||
books.map { update(config.dsl(), it) }
|
||||
}
|
||||
|
|
@ -233,7 +233,7 @@ class BookDao(
|
|||
}
|
||||
}
|
||||
|
||||
override fun deleteByBookIds(bookIds: Collection<String>) {
|
||||
override fun delete(bookIds: Collection<String>) {
|
||||
dsl.transaction { config ->
|
||||
with(config.dsl()) {
|
||||
deleteFrom(b).where(b.ID.`in`(bookIds)).execute()
|
||||
|
|
|
|||
|
|
@ -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<String>?,
|
||||
|
|
@ -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<String>?, pageable: Pageable): Page<BookDto> {
|
||||
override fun findAllOnDeck(userId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<BookDto> {
|
||||
val seriesIds = dsl.select(s.ID)
|
||||
.from(s)
|
||||
.leftJoin(b).on(s.ID.eq(b.SERIES_ID))
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ class BookMetadataDao(
|
|||
override fun findByIdOrNull(bookId: String): BookMetadata? =
|
||||
find(dsl, listOf(bookId)).firstOrNull()
|
||||
|
||||
override fun findByIds(bookIds: Collection<String>): Collection<BookMetadata> =
|
||||
override fun findAllByIds(bookIds: Collection<String>): Collection<BookMetadata> =
|
||||
find(dsl, bookIds)
|
||||
|
||||
private fun find(dsl: DSLContext, bookIds: Collection<String>) =
|
||||
|
|
@ -52,10 +52,10 @@ class BookMetadataDao(
|
|||
.toSet()
|
||||
|
||||
override fun insert(metadata: BookMetadata) {
|
||||
insertMany(listOf(metadata))
|
||||
insert(listOf(metadata))
|
||||
}
|
||||
|
||||
override fun insertMany(metadatas: Collection<BookMetadata>) {
|
||||
override fun insert(metadatas: Collection<BookMetadata>) {
|
||||
if (metadatas.isNotEmpty()) {
|
||||
dsl.transaction { config ->
|
||||
config.dsl().batch(
|
||||
|
|
@ -111,7 +111,7 @@ class BookMetadataDao(
|
|||
}
|
||||
}
|
||||
|
||||
override fun updateMany(metadatas: Collection<BookMetadata>) {
|
||||
override fun update(metadatas: Collection<BookMetadata>) {
|
||||
dsl.transaction { config ->
|
||||
metadatas.forEach { updateMetadata(config.dsl(), it) }
|
||||
}
|
||||
|
|
@ -192,7 +192,7 @@ class BookMetadataDao(
|
|||
}
|
||||
}
|
||||
|
||||
override fun deleteByBookIds(bookIds: Collection<String>) {
|
||||
override fun delete(bookIds: Collection<String>) {
|
||||
dsl.transaction { config ->
|
||||
with(config.dsl()) {
|
||||
deleteFrom(a).where(a.BOOK_ID.`in`(bookIds)).execute()
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ class LibraryDao(
|
|||
.fetchInto(l)
|
||||
.map { it.toDomain() }
|
||||
|
||||
override fun findAllById(libraryIds: Collection<String>): Collection<Library> =
|
||||
override fun findAllByIds(libraryIds: Collection<String>): Collection<Library> =
|
||||
dsl.selectFrom(l)
|
||||
.where(l.ID.`in`(libraryIds))
|
||||
.fetchInto(l)
|
||||
|
|
|
|||
|
|
@ -59,10 +59,10 @@ class MediaDao(
|
|||
}.first()
|
||||
|
||||
override fun insert(media: Media) {
|
||||
insertMany(listOf(media))
|
||||
insert(listOf(media))
|
||||
}
|
||||
|
||||
override fun insertMany(medias: Collection<Media>) {
|
||||
override fun insert(medias: Collection<Media>) {
|
||||
if (medias.isNotEmpty()) {
|
||||
dsl.transaction { config ->
|
||||
config.dsl().batch(
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ class ReadListDao(
|
|||
.fetchAndMap(filterOnLibraryIds)
|
||||
.firstOrNull()
|
||||
|
||||
override fun findAll(search: String?, pageable: Pageable): Page<ReadList> {
|
||||
override fun searchAll(search: String?, pageable: Pageable): Page<ReadList> {
|
||||
val conditions = search?.let { rl.NAME.containsIgnoreCase(it) }
|
||||
?: DSL.trueCondition()
|
||||
|
||||
|
|
@ -70,7 +70,7 @@ class ReadListDao(
|
|||
)
|
||||
}
|
||||
|
||||
override fun findAllByLibraries(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String?, pageable: Pageable): Page<ReadList> {
|
||||
override fun findAllByLibraryIds(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String?, pageable: Pageable): Page<ReadList> {
|
||||
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<String>?): Collection<ReadList> {
|
||||
override fun findAllContainingBookId(containsBookId: String, filterOnLibraryIds: Collection<String>?): Collection<ReadList> {
|
||||
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<String>) {
|
||||
override fun removeBooksFromAll(bookIds: Collection<String>) {
|
||||
dsl.deleteFrom(rlb)
|
||||
.where(rlb.BOOK_ID.`in`(bookIds))
|
||||
.execute()
|
||||
|
|
|
|||
|
|
@ -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<ReadProgress> =
|
||||
override fun findAllByUserId(userId: String): Collection<ReadProgress> =
|
||||
dsl.selectFrom(r)
|
||||
.where(r.USER_ID.eq(userId))
|
||||
.fetchInto(r)
|
||||
.map { it.toDomain() }
|
||||
|
||||
override fun findByBookId(bookId: String): Collection<ReadProgress> =
|
||||
override fun findAllByBookId(bookId: String): Collection<ReadProgress> =
|
||||
dsl.selectFrom(r)
|
||||
.where(r.BOOK_ID.eq(bookId))
|
||||
.fetchInto(r)
|
||||
|
|
@ -50,7 +50,7 @@ class ReadProgressDao(
|
|||
}
|
||||
}
|
||||
|
||||
override fun saveAll(readProgresses: Collection<ReadProgress>) {
|
||||
override fun save(readProgresses: Collection<ReadProgress>) {
|
||||
dsl.transaction { config ->
|
||||
val queries = readProgresses.map { config.dsl().saveQuery(it) }
|
||||
config.dsl().batch(queries).execute()
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -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<String>?): List<Author> =
|
||||
override fun findAllAuthorsByName(search: String, filterOnLibraryIds: Collection<String>?): List<Author> =
|
||||
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<String>?): List<Author> =
|
||||
override fun findAllAuthorsByNameAndLibrary(search: String, libraryId: String, filterOnLibraryIds: Collection<String>?): List<Author> =
|
||||
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<String>?): List<Author> =
|
||||
override fun findAllAuthorsByNameAndCollection(search: String, collectionId: String, filterOnLibraryIds: Collection<String>?): List<Author> =
|
||||
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<String>?): List<Author> =
|
||||
override fun findAllAuthorsByNameAndSeries(search: String, seriesId: String, filterOnLibraryIds: Collection<String>?): List<Author> =
|
||||
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<String>?, pageable: Pageable): Page<Author> {
|
||||
override fun findAllAuthorsByName(search: String, role: String?, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
return findAuthorsByName(search, role, filterOnLibraryIds, pageable, null)
|
||||
}
|
||||
|
||||
override fun findAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
override fun findAllAuthorsByNameAndLibrary(search: String, role: String?, libraryId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.LIBRARY, libraryId))
|
||||
}
|
||||
|
||||
override fun findAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
override fun findAllAuthorsByNameAndCollection(search: String, role: String?, collectionId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.COLLECTION, collectionId))
|
||||
}
|
||||
|
||||
override fun findAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
override fun findAllAuthorsByNameAndSeries(search: String, role: String?, seriesId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<Author> {
|
||||
return findAuthorsByName(search, role, filterOnLibraryIds, pageable, FilterBy(FilterByType.SERIES, seriesId))
|
||||
}
|
||||
|
||||
|
|
@ -138,7 +138,7 @@ class ReferentialDao(
|
|||
)
|
||||
}
|
||||
|
||||
override fun findAuthorsNamesByName(search: String, filterOnLibraryIds: Collection<String>?): List<String> =
|
||||
override fun findAllAuthorsNamesByName(search: String, filterOnLibraryIds: Collection<String>?): List<String> =
|
||||
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<String>?): List<String> =
|
||||
override fun findAllAuthorsRoles(filterOnLibraryIds: Collection<String>?): List<String> =
|
||||
dsl.selectDistinct(a.ROLE)
|
||||
.from(a)
|
||||
.apply {
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ class SeriesCollectionDao(
|
|||
.fetchAndMap(filterOnLibraryIds)
|
||||
.firstOrNull()
|
||||
|
||||
override fun findAll(search: String?, pageable: Pageable): Page<SeriesCollection> {
|
||||
override fun searchAll(search: String?, pageable: Pageable): Page<SeriesCollection> {
|
||||
val conditions = search?.let { c.NAME.containsIgnoreCase(it) }
|
||||
?: DSL.trueCondition()
|
||||
|
||||
|
|
@ -69,7 +69,7 @@ class SeriesCollectionDao(
|
|||
)
|
||||
}
|
||||
|
||||
override fun findAllByLibraries(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String?, pageable: Pageable): Page<SeriesCollection> {
|
||||
override fun findAllByLibraryIds(belongsToLibraryIds: Collection<String>, filterOnLibraryIds: Collection<String>?, search: String?, pageable: Pageable): Page<SeriesCollection> {
|
||||
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<String>?): Collection<SeriesCollection> {
|
||||
override fun findAllContainingSeriesId(containsSeriesId: String, filterOnLibraryIds: Collection<String>?): Collection<SeriesCollection> {
|
||||
val ids = dsl.select(c.ID)
|
||||
.from(c)
|
||||
.leftJoin(cs).on(c.ID.eq(cs.COLLECTION_ID))
|
||||
|
|
|
|||
|
|
@ -33,25 +33,25 @@ class SeriesDao(
|
|||
.fetchOneInto(s)
|
||||
?.toDomain()
|
||||
|
||||
override fun findByLibraryId(libraryId: String): List<Series> =
|
||||
override fun findAllByLibraryId(libraryId: String): List<Series> =
|
||||
dsl.selectFrom(s)
|
||||
.where(s.LIBRARY_ID.eq(libraryId))
|
||||
.fetchInto(s)
|
||||
.map { it.toDomain() }
|
||||
|
||||
override fun findByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection<URL>): List<Series> =
|
||||
override fun findAllByLibraryIdAndUrlNotIn(libraryId: String, urls: Collection<URL>): List<Series> =
|
||||
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<Series> =
|
||||
override fun findAllByTitle(title: String): Collection<Series> =
|
||||
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<String> =
|
||||
override fun findAllIdsByLibraryId(libraryId: String): Collection<String> =
|
||||
dsl.select(s.ID)
|
||||
.from(s)
|
||||
.where(s.LIBRARY_ID.eq(libraryId))
|
||||
|
|
@ -121,7 +121,7 @@ class SeriesDao(
|
|||
}
|
||||
}
|
||||
|
||||
override fun deleteAll(seriesIds: Collection<String>) {
|
||||
override fun delete(seriesIds: Collection<String>) {
|
||||
dsl.transaction { config ->
|
||||
with(config.dsl()) {
|
||||
deleteFrom(s).where(s.ID.`in`(seriesIds)).execute()
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -14,20 +14,20 @@ class ThumbnailBookDao(
|
|||
) : ThumbnailBookRepository {
|
||||
private val tb = Tables.THUMBNAIL_BOOK
|
||||
|
||||
override fun findByBookId(bookId: String): Collection<ThumbnailBook> =
|
||||
override fun findAllByBookId(bookId: String): Collection<ThumbnailBook> =
|
||||
dsl.selectFrom(tb)
|
||||
.where(tb.BOOK_ID.eq(bookId))
|
||||
.fetchInto(tb)
|
||||
.map { it.toDomain() }
|
||||
|
||||
override fun findByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection<ThumbnailBook> =
|
||||
override fun findAllByBookIdAndType(bookId: String, type: ThumbnailBook.Type): Collection<ThumbnailBook> =
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -14,13 +14,13 @@ class ThumbnailSeriesDao(
|
|||
) : ThumbnailSeriesRepository {
|
||||
private val ts = Tables.THUMBNAIL_SERIES
|
||||
|
||||
override fun findBySeriesId(seriesId: String): Collection<ThumbnailSeries> =
|
||||
override fun findAllBySeriesId(seriesId: String): Collection<ThumbnailSeries> =
|
||||
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)
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ class BookController(
|
|||
@RequestParam(name = "library_id", required = false) libraryIds: List<String>?,
|
||||
@Parameter(hidden = true) page: Pageable
|
||||
): Page<BookDto> =
|
||||
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<ReadListDto> {
|
||||
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)
|
||||
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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),
|
||||
|
|
|
|||
|
|
@ -32,10 +32,10 @@ class ReferentialController(
|
|||
): List<AuthorDto> =
|
||||
|
||||
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<String> =
|
||||
referentialRepository.findAuthorsNamesByName(search, principal.user.getAuthorizedLibraryIds(null))
|
||||
referentialRepository.findAllAuthorsNamesByName(search, principal.user.getAuthorizedLibraryIds(null))
|
||||
|
||||
@GetMapping("v1/authors/roles")
|
||||
fun getAuthorsRoles(
|
||||
@AuthenticationPrincipal principal: KomgaPrincipal,
|
||||
): List<String> =
|
||||
referentialRepository.findAuthorsRoles(principal.user.getAuthorizedLibraryIds(null))
|
||||
referentialRepository.findAllAuthorsRoles(principal.user.getAuthorizedLibraryIds(null))
|
||||
|
||||
@GetMapping("v1/genres")
|
||||
fun getGenres(
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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 ->
|
||||
|
|
|
|||
|
|
@ -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<ByteArray> =
|
||||
transientBookRepository.findById(id)?.let {
|
||||
transientBookRepository.findByIdOrNull(id)?.let {
|
||||
try {
|
||||
val pageContent = transientBookLifecycle.getBookPage(it, pageNumber)
|
||||
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
)
|
||||
|
|
|
|||
|
|
@ -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<String>?,
|
||||
|
|
@ -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<String>?
|
||||
): BookDto?
|
||||
|
||||
fun findNextInReadList(
|
||||
fun findNextInReadListOrNull(
|
||||
readListId: String,
|
||||
bookId: String,
|
||||
userId: String,
|
||||
filterOnLibraryIds: Collection<String>?
|
||||
): BookDto?
|
||||
|
||||
fun findOnDeck(userId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<BookDto>
|
||||
fun findAllOnDeck(userId: String, filterOnLibraryIds: Collection<String>?, pageable: Pageable): Page<BookDto>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<SeriesDto>
|
||||
fun findByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findByIdOrNull(seriesId: String, userId: String): SeriesDto?
|
||||
|
||||
fun findAll(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findAllByCollectionId(collectionId: String, search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
fun findAllRecentlyUpdated(search: SeriesSearchWithReadProgress, userId: String, pageable: Pageable): Page<SeriesDto>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)!!) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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()) {
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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")
|
||||
|
|
|
|||
|
|
@ -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)) }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue