Skip to content

Commit

Permalink
feat(api): search series by tag
Browse files Browse the repository at this point in the history
  • Loading branch information
gotson committed Aug 24, 2020
1 parent f46f1a0 commit 7bd1de6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ open class SeriesSearch(
val searchTerm: String? = null,
val metadataStatus: Collection<SeriesMetadata.Status>? = null,
val publishers: Collection<String>? = null,
val languages: Collection<String>? = null
val languages: Collection<String>? = null,
val tags: Collection<String>? = null
)

class SeriesSearchWithReadProgress(
Expand All @@ -16,5 +17,6 @@ class SeriesSearchWithReadProgress(
metadataStatus: Collection<SeriesMetadata.Status>? = null,
publishers: Collection<String>? = null,
languages: Collection<String>? = null,
tags: Collection<String>? = null,
val readStatus: Collection<ReadStatus>? = null
) : SeriesSearch(libraryIds, collectionIds, searchTerm, metadataStatus, publishers, languages)
) : SeriesSearch(libraryIds, collectionIds, searchTerm, metadataStatus, publishers, languages, tags)
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ class SeriesDtoDao(
.leftJoin(b).on(s.ID.eq(b.SERIES_ID))
.leftJoin(d).on(s.ID.eq(d.SERIES_ID))
.leftJoin(r).on(b.ID.eq(r.BOOK_ID))
.leftJoin(st).on(s.ID.eq(st.SERIES_ID))
.and(readProgressCondition(userId))
.leftJoin(cs).on(s.ID.eq(cs.SERIES_ID))

Expand All @@ -114,6 +115,7 @@ class SeriesDtoDao(
.leftJoin(b).on(s.ID.eq(b.SERIES_ID))
.leftJoin(d).on(s.ID.eq(d.SERIES_ID))
.leftJoin(r).on(b.ID.eq(r.BOOK_ID))
.leftJoin(st).on(s.ID.eq(st.SERIES_ID))
.and(readProgressCondition(userId))
.leftJoin(cs).on(s.ID.eq(cs.SERIES_ID))
.where(conditions)
Expand Down Expand Up @@ -187,6 +189,7 @@ class SeriesDtoDao(
metadataStatus?.let { c = c.and(d.STATUS.`in`(it)) }
publishers?.let { publishers -> c = c.and(lower(d.PUBLISHER).`in`(publishers.map { it.toLowerCase() })) }
languages?.let { languages -> c = c.and(lower(d.LANGUAGE).`in`(languages.map { it.toLowerCase() })) }
tags?.let { tags -> c = c.and(lower(st.TAG).`in`(tags.map { it.toLowerCase() })) }

return c
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@ class SeriesController(
@RequestParam(name = "read_status", required = false) readStatus: List<ReadStatus>?,
@RequestParam(name = "publisher", required = false) publishers: List<String>?,
@RequestParam(name = "language", required = false) languages: List<String>?,
@RequestParam(name = "tag", required = false) tags: List<String>?,
@RequestParam(name = "unpaged", required = false) unpaged: Boolean = false,
@Parameter(hidden = true) page: Pageable
): Page<SeriesDto> {
Expand All @@ -101,7 +102,8 @@ class SeriesController(
metadataStatus = metadataStatus,
readStatus = readStatus,
publishers = publishers,
languages = languages
languages = languages,
tags = tags
)

return seriesDtoRepository.findAll(seriesSearch, principal.user.id, pageRequest)
Expand Down

0 comments on commit 7bd1de6

Please sign in to comment.