From d64fe030655008d494979dc9dfc3e553412a0eb2 Mon Sep 17 00:00:00 2001 From: Gauthier Roebroeck Date: Thu, 12 Dec 2024 16:44:15 +0800 Subject: [PATCH] style: ktlint format --- .../domain/service/SyncPointLifecycle.kt | 40 ++-- .../interfaces/api/rest/SeriesController.kt | 198 +++++++++--------- .../komga/domain/model/SeriesSearchTest.kt | 4 +- 3 files changed, 121 insertions(+), 121 deletions(-) diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/service/SyncPointLifecycle.kt b/komga/src/main/kotlin/org/gotson/komga/domain/service/SyncPointLifecycle.kt index 67e92f0d0bb..0b22a9de5fc 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/service/SyncPointLifecycle.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/service/SyncPointLifecycle.kt @@ -25,27 +25,27 @@ class SyncPointLifecycle( val context = SearchContext(user) val syncPoint = - syncPointRepository. - create( - apiKeyId, - BookSearch( - SearchCondition.AllOfBook( - buildList { - libraryIds?.let { - add( - SearchCondition.AnyOfBook( - it.map { libraryId -> SearchCondition.LibraryId(SearchOperator.Is(libraryId)) }, - ), - ) - } - add(SearchCondition.MediaStatus(SearchOperator.Is(Media.Status.READY))) - add(SearchCondition.MediaProfile(SearchOperator.Is(MediaProfile.EPUB))) - add(SearchCondition.Deleted(SearchOperator.IsFalse)) - }, + syncPointRepository + .create( + apiKeyId, + BookSearch( + SearchCondition.AllOfBook( + buildList { + libraryIds?.let { + add( + SearchCondition.AnyOfBook( + it.map { libraryId -> SearchCondition.LibraryId(SearchOperator.Is(libraryId)) }, + ), + ) + } + add(SearchCondition.MediaStatus(SearchOperator.Is(Media.Status.READY))) + add(SearchCondition.MediaProfile(SearchOperator.Is(MediaProfile.EPUB))) + add(SearchCondition.Deleted(SearchOperator.IsFalse)) + }, + ), ), - ), - context, - ) + context, + ) syncPointRepository.addOnDeck(syncPoint.id, context, libraryIds) diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/SeriesController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/SeriesController.kt index 86bcb295b29..3dcc457ae83 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/SeriesController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/api/rest/SeriesController.kt @@ -177,45 +177,45 @@ class SeriesController( val seriesSearch = SeriesSearch( condition = - SearchCondition.AllOfSeries( - buildList { - if (!libraryIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(libraryIds.map { SearchCondition.LibraryId(SearchOperator.Is(it)) })) - if (!collectionIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(collectionIds.map { SearchCondition.CollectionId(SearchOperator.Is(it)) })) - if (!metadataStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(metadataStatus.map { SearchCondition.SeriesStatus(SearchOperator.Is(it)) })) - if (!publishers.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(publishers.map { SearchCondition.Publisher(SearchOperator.Is(it)) })) - if (!languages.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(languages.map { SearchCondition.Language(SearchOperator.Is(it)) })) - if (!genres.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(genres.map { SearchCondition.Genre(SearchOperator.Is(it)) })) - if (!tags.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(tags.map { SearchCondition.Tag(SearchOperator.Is(it)) })) - if (!readStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(readStatus.map { SearchCondition.ReadStatus(SearchOperator.Is(it)) })) - if (!authors.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(authors.map { SearchCondition.Author(SearchOperator.Is(SearchCondition.AuthorMatch(it.name, it.role))) })) - if (!ageRatings.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(ageRatings.map { it.toIntOrNull()?.let { ageRating -> SearchCondition.AgeRating(SearchOperator.Is(ageRating)) } ?: SearchCondition.AgeRating(SearchOperator.IsNullT()) })) - if (!releaseYears.isNullOrEmpty()) - add( - SearchCondition.AnyOfSeries( - releaseYears.mapNotNull { it.toIntOrNull() }.map { releaseYear -> - SearchCondition.AllOfSeries( - SearchCondition.ReleaseDate(SearchOperator.After(ZonedDateTime.of(releaseYear - 1, 12, 31, 12, 0, 0, 0, ZoneOffset.UTC))), - SearchCondition.ReleaseDate(SearchOperator.Before(ZonedDateTime.of(releaseYear + 1, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))), - ) - }, - ), - ) - - if (!sharingLabels.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(sharingLabels.map { SearchCondition.SharingLabel(SearchOperator.Is(it)) })) - oneshot?.let { add(SearchCondition.OneShot(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - complete?.let { add(SearchCondition.Complete(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - deleted?.let { add(SearchCondition.Deleted(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - }, - ), + SearchCondition.AllOfSeries( + buildList { + if (!libraryIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(libraryIds.map { SearchCondition.LibraryId(SearchOperator.Is(it)) })) + if (!collectionIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(collectionIds.map { SearchCondition.CollectionId(SearchOperator.Is(it)) })) + if (!metadataStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(metadataStatus.map { SearchCondition.SeriesStatus(SearchOperator.Is(it)) })) + if (!publishers.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(publishers.map { SearchCondition.Publisher(SearchOperator.Is(it)) })) + if (!languages.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(languages.map { SearchCondition.Language(SearchOperator.Is(it)) })) + if (!genres.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(genres.map { SearchCondition.Genre(SearchOperator.Is(it)) })) + if (!tags.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(tags.map { SearchCondition.Tag(SearchOperator.Is(it)) })) + if (!readStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(readStatus.map { SearchCondition.ReadStatus(SearchOperator.Is(it)) })) + if (!authors.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(authors.map { SearchCondition.Author(SearchOperator.Is(SearchCondition.AuthorMatch(it.name, it.role))) })) + if (!ageRatings.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(ageRatings.map { it.toIntOrNull()?.let { ageRating -> SearchCondition.AgeRating(SearchOperator.Is(ageRating)) } ?: SearchCondition.AgeRating(SearchOperator.IsNullT()) })) + if (!releaseYears.isNullOrEmpty()) + add( + SearchCondition.AnyOfSeries( + releaseYears.mapNotNull { it.toIntOrNull() }.map { releaseYear -> + SearchCondition.AllOfSeries( + SearchCondition.ReleaseDate(SearchOperator.After(ZonedDateTime.of(releaseYear - 1, 12, 31, 12, 0, 0, 0, ZoneOffset.UTC))), + SearchCondition.ReleaseDate(SearchOperator.Before(ZonedDateTime.of(releaseYear + 1, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))), + ) + }, + ), + ) + + if (!sharingLabels.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(sharingLabels.map { SearchCondition.SharingLabel(SearchOperator.Is(it)) })) + oneshot?.let { add(SearchCondition.OneShot(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + complete?.let { add(SearchCondition.Complete(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + deleted?.let { add(SearchCondition.Deleted(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + }, + ), fullTextSearch = searchTerm, regexSearch = - searchRegex?.let { - when (it.second.lowercase()) { - "title" -> Pair(it.first, SearchField.TITLE) - "title_sort" -> Pair(it.first, SearchField.TITLE_SORT) - else -> null - } - }, + searchRegex?.let { + when (it.second.lowercase()) { + "title" -> Pair(it.first, SearchField.TITLE) + "title_sort" -> Pair(it.first, SearchField.TITLE_SORT) + else -> null + } + }, ) return seriesDtoRepository.findAll(seriesSearch, SearchContext(principal.user), pageRequest) @@ -288,45 +288,45 @@ class SeriesController( val seriesSearch = SeriesSearch( condition = - SearchCondition.AllOfSeries( - buildList { - if (!libraryIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(libraryIds.map { SearchCondition.LibraryId(SearchOperator.Is(it)) })) - if (!collectionIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(collectionIds.map { SearchCondition.CollectionId(SearchOperator.Is(it)) })) - if (!metadataStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(metadataStatus.map { SearchCondition.SeriesStatus(SearchOperator.Is(it)) })) - if (!publishers.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(publishers.map { SearchCondition.Publisher(SearchOperator.Is(it)) })) - if (!languages.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(languages.map { SearchCondition.Language(SearchOperator.Is(it)) })) - if (!genres.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(genres.map { SearchCondition.Genre(SearchOperator.Is(it)) })) - if (!tags.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(tags.map { SearchCondition.Tag(SearchOperator.Is(it)) })) - if (!readStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(readStatus.map { SearchCondition.ReadStatus(SearchOperator.Is(it)) })) - if (!authors.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(authors.map { SearchCondition.Author(SearchOperator.Is(SearchCondition.AuthorMatch(it.name, it.role))) })) - if (!ageRatings.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(ageRatings.map { it.toIntOrNull()?.let { ageRating -> SearchCondition.AgeRating(SearchOperator.Is(ageRating)) } ?: SearchCondition.AgeRating(SearchOperator.IsNullT()) })) - if (!releaseYears.isNullOrEmpty()) - add( - SearchCondition.AnyOfSeries( - releaseYears.mapNotNull { it.toIntOrNull() }.map { releaseYear -> - SearchCondition.AllOfSeries( - SearchCondition.ReleaseDate(SearchOperator.After(ZonedDateTime.of(releaseYear - 1, 12, 31, 12, 0, 0, 0, ZoneOffset.UTC))), - SearchCondition.ReleaseDate(SearchOperator.Before(ZonedDateTime.of(releaseYear + 1, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))), - ) - }, - ), - ) - - if (!sharingLabels.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(sharingLabels.map { SearchCondition.SharingLabel(SearchOperator.Is(it)) })) - oneshot?.let { add(SearchCondition.OneShot(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - complete?.let { add(SearchCondition.Complete(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - deleted?.let { add(SearchCondition.Deleted(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } - }, - ), + SearchCondition.AllOfSeries( + buildList { + if (!libraryIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(libraryIds.map { SearchCondition.LibraryId(SearchOperator.Is(it)) })) + if (!collectionIds.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(collectionIds.map { SearchCondition.CollectionId(SearchOperator.Is(it)) })) + if (!metadataStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(metadataStatus.map { SearchCondition.SeriesStatus(SearchOperator.Is(it)) })) + if (!publishers.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(publishers.map { SearchCondition.Publisher(SearchOperator.Is(it)) })) + if (!languages.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(languages.map { SearchCondition.Language(SearchOperator.Is(it)) })) + if (!genres.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(genres.map { SearchCondition.Genre(SearchOperator.Is(it)) })) + if (!tags.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(tags.map { SearchCondition.Tag(SearchOperator.Is(it)) })) + if (!readStatus.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(readStatus.map { SearchCondition.ReadStatus(SearchOperator.Is(it)) })) + if (!authors.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(authors.map { SearchCondition.Author(SearchOperator.Is(SearchCondition.AuthorMatch(it.name, it.role))) })) + if (!ageRatings.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(ageRatings.map { it.toIntOrNull()?.let { ageRating -> SearchCondition.AgeRating(SearchOperator.Is(ageRating)) } ?: SearchCondition.AgeRating(SearchOperator.IsNullT()) })) + if (!releaseYears.isNullOrEmpty()) + add( + SearchCondition.AnyOfSeries( + releaseYears.mapNotNull { it.toIntOrNull() }.map { releaseYear -> + SearchCondition.AllOfSeries( + SearchCondition.ReleaseDate(SearchOperator.After(ZonedDateTime.of(releaseYear - 1, 12, 31, 12, 0, 0, 0, ZoneOffset.UTC))), + SearchCondition.ReleaseDate(SearchOperator.Before(ZonedDateTime.of(releaseYear + 1, 1, 1, 12, 0, 0, 0, ZoneOffset.UTC))), + ) + }, + ), + ) + + if (!sharingLabels.isNullOrEmpty()) add(SearchCondition.AnyOfSeries(sharingLabels.map { SearchCondition.SharingLabel(SearchOperator.Is(it)) })) + oneshot?.let { add(SearchCondition.OneShot(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + complete?.let { add(SearchCondition.Complete(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + deleted?.let { add(SearchCondition.Deleted(if (it) SearchOperator.IsTrue else SearchOperator.IsFalse)) } + }, + ), fullTextSearch = searchTerm, regexSearch = - searchRegex?.let { - when (it.second.lowercase()) { - "title" -> Pair(it.first, SearchField.TITLE) - "title_sort" -> Pair(it.first, SearchField.TITLE_SORT) - else -> null - } - }, + searchRegex?.let { + when (it.second.lowercase()) { + "title" -> Pair(it.first, SearchField.TITLE) + "title_sort" -> Pair(it.first, SearchField.TITLE_SORT) + else -> null + } + }, ) return seriesDtoRepository.countByFirstCharacter(seriesSearch, SearchContext(principal.user)) @@ -672,41 +672,41 @@ class SeriesController( ageRating = if (isSet("ageRating")) ageRating else existing.ageRating, ageRatingLock = ageRatingLock ?: existing.ageRatingLock, genres = - if (isSet("genres")) { - if (genres != null) genres!! else emptySet() - } else { - existing.genres - }, + if (isSet("genres")) { + if (genres != null) genres!! else emptySet() + } else { + existing.genres + }, genresLock = genresLock ?: existing.genresLock, tags = - if (isSet("tags")) { - if (tags != null) tags!! else emptySet() - } else { - existing.tags - }, + if (isSet("tags")) { + if (tags != null) tags!! else emptySet() + } else { + existing.tags + }, tagsLock = tagsLock ?: existing.tagsLock, totalBookCount = if (isSet("totalBookCount")) totalBookCount else existing.totalBookCount, totalBookCountLock = totalBookCountLock ?: existing.totalBookCountLock, sharingLabels = - if (isSet("sharingLabels")) { - if (sharingLabels != null) sharingLabels!! else emptySet() - } else { - existing.sharingLabels - }, + if (isSet("sharingLabels")) { + if (sharingLabels != null) sharingLabels!! else emptySet() + } else { + existing.sharingLabels + }, sharingLabelsLock = sharingLabelsLock ?: existing.sharingLabelsLock, links = - if (isSet("links")) { - if (links != null) links!!.map { WebLink(it.label!!, URI(it.url!!)) } else emptyList() - } else { - existing.links - }, + if (isSet("links")) { + if (links != null) links!!.map { WebLink(it.label!!, URI(it.url!!)) } else emptyList() + } else { + existing.links + }, linksLock = linksLock ?: existing.linksLock, alternateTitles = - if (isSet("alternateTitles")) { - if (alternateTitles != null) alternateTitles!!.map { AlternateTitle(it.label!!, it.title!!) } else emptyList() - } else { - existing.alternateTitles - }, + if (isSet("alternateTitles")) { + if (alternateTitles != null) alternateTitles!!.map { AlternateTitle(it.label!!, it.title!!) } else emptyList() + } else { + existing.alternateTitles + }, alternateTitlesLock = alternateTitlesLock ?: existing.alternateTitlesLock, ) } diff --git a/komga/src/test/kotlin/org/gotson/komga/domain/model/SeriesSearchTest.kt b/komga/src/test/kotlin/org/gotson/komga/domain/model/SeriesSearchTest.kt index bfd0e13b09c..07abb127983 100644 --- a/komga/src/test/kotlin/org/gotson/komga/domain/model/SeriesSearchTest.kt +++ b/komga/src/test/kotlin/org/gotson/komga/domain/model/SeriesSearchTest.kt @@ -12,7 +12,7 @@ import java.time.ZoneOffset import java.time.ZonedDateTime @SpringBootTest - class SeriesSearchTest( +class SeriesSearchTest( @Autowired private val mapper: ObjectMapper, ) { private val writer = mapper.writerWithDefaultPrettyPrinter() @@ -23,7 +23,7 @@ import java.time.ZonedDateTime SeriesSearch( SearchCondition.AllOfSeries( SearchCondition.AnyOfSeries( - emptyList() + emptyList(), ), SearchCondition.AnyOfSeries( SearchCondition.LibraryId(SearchOperator.Is("library1")),