Skip to content

Commit

Permalink
style: ktlint format
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Dec 12, 2024
1 parent d93bc3d commit d64fe03
Show file tree
Hide file tree
Showing 3 changed files with 121 additions and 121 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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))
Expand Down Expand Up @@ -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,
)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -23,7 +23,7 @@ import java.time.ZonedDateTime
SeriesSearch(
SearchCondition.AllOfSeries(
SearchCondition.AnyOfSeries(
emptyList()
emptyList(),
),
SearchCondition.AnyOfSeries(
SearchCondition.LibraryId(SearchOperator.Is("library1")),
Expand Down

0 comments on commit d64fe03

Please sign in to comment.