diff --git a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt index 3121fbaed..2c2dd86a1 100644 --- a/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt +++ b/komga/src/main/kotlin/org/gotson/komga/domain/persistence/ReferentialRepository.kt @@ -1,5 +1,7 @@ package org.gotson.komga.domain.persistence +import java.time.LocalDate + interface ReferentialRepository { fun findAuthorsByName(search: String): List @@ -23,5 +25,9 @@ interface ReferentialRepository { fun findAllAgeRatings(): Set fun findAllAgeRatingsByLibrary(libraryId: String): Set - fun findAllAgeRatingsByCollection(collectionId: String): Iterable + fun findAllAgeRatingsByCollection(collectionId: String): Set + + fun findAllSeriesReleaseDates(): Set + fun findAllSeriesReleaseDatesByLibrary(libraryId: String): Set + fun findAllSeriesReleaseDatesByCollection(collectionId: String): Set } diff --git a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt index ed6929ff2..64e0d73b8 100644 --- a/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt +++ b/komga/src/main/kotlin/org/gotson/komga/infrastructure/jooq/ReferentialDao.kt @@ -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 = + override fun findAllAgeRatingsByCollection(collectionId: String): Set = 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 = + 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 = + 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 = + 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) } diff --git a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt index 6be9da2db..4eb28e7d5 100644 --- a/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt +++ b/komga/src/main/kotlin/org/gotson/komga/interfaces/rest/ReferentialController.kt @@ -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 = + when { + libraryId != null -> referentialRepository.findAllSeriesReleaseDatesByLibrary(libraryId) + collectionId != null -> referentialRepository.findAllSeriesReleaseDatesByCollection(collectionId) + else -> referentialRepository.findAllSeriesReleaseDates() + }.map { it.year.toString() }.toSet() } diff --git a/komga/src/main/resources/application-dev.yml b/komga/src/main/resources/application-dev.yml index 3e071dc20..9aef2c2e5 100644 --- a/komga/src/main/resources/application-dev.yml +++ b/komga/src/main/resources/application-dev.yml @@ -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