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 42f29f89..50bb38db 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 @@ -31,6 +31,7 @@ class SeriesSearchWithReadProgress( val releaseYears: Collection? = null, val readStatus: Collection? = null, val authors: Collection? = null, + val sharingLabels: Collection? = null, ) : SeriesSearch( libraryIds = libraryIds, collectionIds = collectionIds, 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 fdfa6ec7..c9809737 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 @@ -139,6 +139,7 @@ class SeriesDtoDao( } .apply { if (joinConditions.collection) leftJoin(cs).on(s.ID.eq(cs.SERIES_ID)) } .apply { if (joinConditions.aggregationAuthor) leftJoin(bmaa).on(s.ID.eq(bmaa.SERIES_ID)) } + .apply { if (joinConditions.sharingLabel) leftJoin(sl).on(s.ID.eq(sl.SERIES_ID)) } .where(conditions) .and(searchCondition) .groupBy(firstChar) @@ -172,6 +173,7 @@ class SeriesDtoDao( } .apply { if (joinConditions.collection) leftJoin(cs).on(s.ID.eq(cs.SERIES_ID)) } .apply { if (joinConditions.aggregationAuthor) leftJoin(bmaa).on(s.ID.eq(bmaa.SERIES_ID)) } + .apply { if (joinConditions.sharingLabel) leftJoin(sl).on(s.ID.eq(sl.SERIES_ID)) } private fun findAll( conditions: Condition, @@ -196,6 +198,7 @@ class SeriesDtoDao( } .apply { if (joinConditions.collection) leftJoin(cs).on(s.ID.eq(cs.SERIES_ID)) } .apply { if (joinConditions.aggregationAuthor) leftJoin(bmaa).on(s.ID.eq(bmaa.SERIES_ID)) } + .apply { if (joinConditions.sharingLabel) leftJoin(sl).on(s.ID.eq(sl.SERIES_ID)) } .where(conditions) .and(searchCondition) .fetchOne(countDistinct(s.ID)) ?: 0 @@ -317,6 +320,7 @@ class SeriesDtoDao( } c = c.and(ca) } + if (!sharingLabels.isNullOrEmpty()) c = c.and(sl.LABEL.collate(SqliteUdfDataSource.collationUnicode3).`in`(sharingLabels)) if (!readStatus.isNullOrEmpty()) { val cr = readStatus.map { when (it) { @@ -344,6 +348,7 @@ class SeriesDtoDao( tag = !tags.isNullOrEmpty(), collection = !collectionIds.isNullOrEmpty(), aggregationAuthor = !authors.isNullOrEmpty(), + sharingLabel = !sharingLabels.isNullOrEmpty(), ) private data class JoinConditions( @@ -352,6 +357,7 @@ class SeriesDtoDao( val tag: Boolean = false, val collection: Boolean = false, val aggregationAuthor: Boolean = false, + val sharingLabel: Boolean = false, ) private fun SeriesRecord.toDto( 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 c761516a..8552c30f 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 @@ -139,7 +139,8 @@ class SeriesController( @RequestParam(name = "genre", required = false) genres: List? = null, @RequestParam(name = "tag", required = false) tags: List? = null, @RequestParam(name = "age_rating", required = false) ageRatings: List? = null, - @RequestParam(name = "release_year", required = false) release_years: List? = null, + @RequestParam(name = "release_year", required = false) releaseYears: List? = null, + @RequestParam(name = "sharing_label", required = false) sharingLabels: List? = null, @RequestParam(name = "deleted", required = false) deleted: Boolean? = null, @RequestParam(name = "complete", required = false) complete: Boolean? = null, @RequestParam(name = "unpaged", required = false) unpaged: Boolean = false, @@ -181,8 +182,9 @@ class SeriesController( genres = genres, tags = tags, ageRatings = ageRatings?.map { it.toIntOrNull() }, - releaseYears = release_years, + releaseYears = releaseYears, authors = authors, + sharingLabels = sharingLabels, ) return seriesDtoRepository.findAll(seriesSearch, principal.user.id, pageRequest, principal.user.restrictions) @@ -214,7 +216,8 @@ class SeriesController( @RequestParam(name = "genre", required = false) genres: List?, @RequestParam(name = "tag", required = false) tags: List?, @RequestParam(name = "age_rating", required = false) ageRatings: List?, - @RequestParam(name = "release_year", required = false) release_years: List?, + @RequestParam(name = "release_year", required = false) releaseYears: List?, + @RequestParam(name = "sharing_label", required = false) sharingLabels: List? = null, @RequestParam(name = "deleted", required = false) deleted: Boolean?, @RequestParam(name = "complete", required = false) complete: Boolean?, @Parameter(hidden = true) @Authors authors: List?, @@ -240,8 +243,9 @@ class SeriesController( genres = genres, tags = tags, ageRatings = ageRatings?.map { it.toIntOrNull() }, - releaseYears = release_years, + releaseYears = releaseYears, authors = authors, + sharingLabels = sharingLabels, ) return seriesDtoRepository.countByFirstCharacter(seriesSearch, principal.user.id, principal.user.restrictions)