diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/model/SeriesSearch.kt b/komga/src/main/kotlin/org/gotson/komga/domain/model/SeriesSearch.kt index 278049124..842ba1e93 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/model/SeriesSearch.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/model/SeriesSearch.kt @@ -16,6 +16,7 @@ class SeriesSearchWithReadProgress( val languages: Collection? = null, val genres: Collection? = null, val tags: Collection? = null, + val ageRatings: Collection? = null, val readStatus: Collection? = null ) : SeriesSearch( libraryIds = libraryIds, diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt index 8e0a073c8..73196ba7f 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/SeriesDtoDao.kt @@ -198,6 +198,11 @@ class SeriesDtoDao( if (!languages.isNullOrEmpty()) c = c.and(lower(d.LANGUAGE).`in`(languages.map { it.toLowerCase() })) if (!genres.isNullOrEmpty()) c = c.and(lower(g.GENRE).`in`(genres.map { it.toLowerCase() })) if (!tags.isNullOrEmpty()) c = c.and(lower(st.TAG).`in`(tags.map { it.toLowerCase() })) + if (!ageRatings.isNullOrEmpty()) { + val c1 = if (ageRatings.contains(null)) d.AGE_RATING.isNull else DSL.falseCondition() + val c2 = if (ageRatings.filterNotNull().isNotEmpty()) d.AGE_RATING.`in`(ageRatings.filterNotNull()) else DSL.falseCondition() + c = c.and(c1.or(c2)) + } return c } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt index 77155ea84..cf828b76f 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/SeriesController.kt @@ -81,6 +81,7 @@ class SeriesController( @RequestParam(name = "language", required = false) languages: List?, @RequestParam(name = "genre", required = false) genres: List?, @RequestParam(name = "tag", required = false) tags: List?, + @RequestParam(name = "age_rating", required = false) ageRatings: List?, @RequestParam(name = "unpaged", required = false) unpaged: Boolean = false, @Parameter(hidden = true) page: Pageable ): Page { @@ -105,7 +106,8 @@ class SeriesController( publishers = publishers, languages = languages, genres = genres, - tags = tags + tags = tags, + ageRatings = ageRatings?.map { it.toIntOrNull() } ) return seriesDtoRepository.findAll(seriesSearch, principal.user.id, pageRequest) @@ -311,8 +313,8 @@ class SeriesController( if (genres != null) genres!! else emptySet() } else existing.genres, genresLock = genresLock ?: existing.genresLock, - tags = if(isSet("tags")) { - if(tags != null) tags!! else emptySet() + tags = if (isSet("tags")) { + if (tags != null) tags!! else emptySet() } else existing.tags, tagsLock = tagsLock ?: existing.tagsLock )