mirror of
https://github.com/gotson/komga.git
synced 2025-12-22 00:13:30 +01:00
feat(api): get all release years for series
This commit is contained in:
parent
b3aa6c2740
commit
c68951be84
4 changed files with 49 additions and 3 deletions
|
|
@ -1,5 +1,7 @@
|
|||
package org.gotson.komga.domain.persistence
|
||||
|
||||
import java.time.LocalDate
|
||||
|
||||
interface ReferentialRepository {
|
||||
fun findAuthorsByName(search: String): List<String>
|
||||
|
||||
|
|
@ -23,5 +25,9 @@ interface ReferentialRepository {
|
|||
|
||||
fun findAllAgeRatings(): Set<Int?>
|
||||
fun findAllAgeRatingsByLibrary(libraryId: String): Set<Int?>
|
||||
fun findAllAgeRatingsByCollection(collectionId: String): Iterable<Int?>
|
||||
fun findAllAgeRatingsByCollection(collectionId: String): Set<Int?>
|
||||
|
||||
fun findAllSeriesReleaseDates(): Set<LocalDate>
|
||||
fun findAllSeriesReleaseDatesByLibrary(libraryId: String): Set<LocalDate>
|
||||
fun findAllSeriesReleaseDatesByCollection(collectionId: String): Set<LocalDate>
|
||||
}
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ import org.jooq.DSLContext
|
|||
import org.jooq.impl.DSL.lower
|
||||
import org.jooq.impl.DSL.select
|
||||
import org.springframework.stereotype.Component
|
||||
import java.time.LocalDate
|
||||
|
||||
@Component
|
||||
class ReferentialDao(
|
||||
|
|
@ -14,6 +15,7 @@ class ReferentialDao(
|
|||
|
||||
private val a = Tables.BOOK_METADATA_AUTHOR
|
||||
private val sd = Tables.SERIES_METADATA
|
||||
private val bma = Tables.BOOK_METADATA_AGGREGATION
|
||||
private val s = Tables.SERIES
|
||||
private val b = Tables.BOOK
|
||||
private val g = Tables.SERIES_METADATA_GENRE
|
||||
|
|
@ -157,11 +159,36 @@ class ReferentialDao(
|
|||
.orderBy(sd.AGE_RATING)
|
||||
.fetchSet(sd.AGE_RATING)
|
||||
|
||||
override fun findAllAgeRatingsByCollection(collectionId: String): Iterable<Int?> =
|
||||
override fun findAllAgeRatingsByCollection(collectionId: String): Set<Int?> =
|
||||
dsl.selectDistinct(sd.AGE_RATING)
|
||||
.from(sd)
|
||||
.leftJoin(cs).on(sd.SERIES_ID.eq(cs.SERIES_ID))
|
||||
.where(cs.COLLECTION_ID.eq(collectionId))
|
||||
.orderBy(sd.AGE_RATING)
|
||||
.fetchSet(sd.AGE_RATING)
|
||||
|
||||
override fun findAllSeriesReleaseDates(): Set<LocalDate> =
|
||||
dsl.selectDistinct(bma.RELEASE_DATE)
|
||||
.from(bma)
|
||||
.where(bma.RELEASE_DATE.isNotNull)
|
||||
.orderBy(bma.RELEASE_DATE)
|
||||
.fetchSet(bma.RELEASE_DATE)
|
||||
|
||||
override fun findAllSeriesReleaseDatesByLibrary(libraryId: String): Set<LocalDate> =
|
||||
dsl.selectDistinct(bma.RELEASE_DATE)
|
||||
.from(bma)
|
||||
.leftJoin(s).on(bma.SERIES_ID.eq(s.ID))
|
||||
.where(s.LIBRARY_ID.eq(libraryId))
|
||||
.and(bma.RELEASE_DATE.isNotNull)
|
||||
.orderBy(bma.RELEASE_DATE)
|
||||
.fetchSet(bma.RELEASE_DATE)
|
||||
|
||||
override fun findAllSeriesReleaseDatesByCollection(collectionId: String): Set<LocalDate> =
|
||||
dsl.selectDistinct(bma.RELEASE_DATE)
|
||||
.from(bma)
|
||||
.leftJoin(cs).on(bma.SERIES_ID.eq(cs.SERIES_ID))
|
||||
.where(cs.COLLECTION_ID.eq(collectionId))
|
||||
.and(bma.RELEASE_DATE.isNotNull)
|
||||
.orderBy(bma.RELEASE_DATE)
|
||||
.fetchSet(bma.RELEASE_DATE)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -75,4 +75,15 @@ class ReferentialController(
|
|||
collectionId != null -> referentialRepository.findAllAgeRatingsByCollection(collectionId)
|
||||
else -> referentialRepository.findAllAgeRatings()
|
||||
}.map { it?.toString() ?: "None" }.toSet()
|
||||
|
||||
@GetMapping("/series/release-dates")
|
||||
fun getSeriesReleaseDates(
|
||||
@RequestParam(name = "library_id", required = false) libraryId: String?,
|
||||
@RequestParam(name = "collection_id", required = false) collectionId: String?
|
||||
): Set<String> =
|
||||
when {
|
||||
libraryId != null -> referentialRepository.findAllSeriesReleaseDatesByLibrary(libraryId)
|
||||
collectionId != null -> referentialRepository.findAllSeriesReleaseDatesByCollection(collectionId)
|
||||
else -> referentialRepository.findAllSeriesReleaseDates()
|
||||
}.map { it.year.toString() }.toSet()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -16,13 +16,15 @@ spring:
|
|||
data-directory: ./artemis
|
||||
logging:
|
||||
file:
|
||||
max-history: 1
|
||||
name: komga-dev.log
|
||||
level:
|
||||
org.apache.activemq.audit.message: WARN
|
||||
# org.jooq: DEBUG
|
||||
# web: DEBUG
|
||||
org.gotson.komga: DEBUG
|
||||
logback:
|
||||
rollingpolicy:
|
||||
max-history: 1
|
||||
# org.springframework.jms: DEBUG
|
||||
# org.springframework.security.web.FilterChainProxy: DEBUG
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue