Skip to content

Commit

Permalink
feat(api): search series by age rating
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Aug 28, 2020
1 parent be80d86 commit f51d575
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ class SeriesSearchWithReadProgress(
val languages: Collection<String>? = null,
val genres: Collection<String>? = null,
val tags: Collection<String>? = null,
val ageRatings: Collection<Int?>? = null,
val readStatus: Collection<ReadStatus>? = null
) : SeriesSearch(
libraryIds = libraryIds,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class SeriesController(
@RequestParam(name = "language", required = false) languages: List<String>?,
@RequestParam(name = "genre", required = false) genres: List<String>?,
@RequestParam(name = "tag", required = false) tags: List<String>?,
@RequestParam(name = "age_rating", required = false) ageRatings: List<String>?,
@RequestParam(name = "unpaged", required = false) unpaged: Boolean = false,
@Parameter(hidden = true) page: Pageable
): Page<SeriesDto> {
Expand All @@ -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)
Expand Down Expand Up @@ -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
)
Expand Down

0 comments on commit f51d575

Please sign in to comment.