From 776acd139cc51613a473f932a5ce51dc95653d7b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 15 Dec 2022 09:11:29 +0000 Subject: [PATCH 1/3] Bump opencv from 4.5.5-1 to 4.6.0-0 Bumps [opencv](https://github.com/openpnp/opencv) from 4.5.5-1 to 4.6.0-0. - [Release notes](https://github.com/openpnp/opencv/releases) - [Commits](https://github.com/openpnp/opencv/compare/v4.5.5-1...v4.6.0-0) --- updated-dependencies: - dependency-name: org.openpnp:opencv dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index 34ff74b..b279bdd 100644 --- a/pom.xml +++ b/pom.xml @@ -130,7 +130,7 @@ org.openpnp opencv - 4.5.5-1 + 4.6.0-0 org.pf4j From 1e784e172fe53dce154addfcc8f15015d14f192a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Thu, 29 Dec 2022 09:14:21 +0000 Subject: [PATCH 2/3] Bump kotlin_version from 1.7.21 to 1.8.0 Bumps `kotlin_version` from 1.7.21 to 1.8.0. Updates `kotlin-test-junit5` from 1.7.21 to 1.8.0 - [Release notes](https://github.com/JetBrains/kotlin/releases) - [Changelog](https://github.com/JetBrains/kotlin/blob/master/ChangeLog.md) - [Commits](https://github.com/JetBrains/kotlin/compare/v1.7.21...v1.8.0) Updates `kotlin-maven-plugin` from 1.7.21 to 1.8.0 --- updated-dependencies: - dependency-name: org.jetbrains.kotlin:kotlin-test-junit5 dependency-type: direct:development update-type: version-update:semver-minor - dependency-name: org.jetbrains.kotlin:kotlin-maven-plugin dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index b279bdd..54c7623 100644 --- a/pom.xml +++ b/pom.xml @@ -11,7 +11,7 @@ 2.2.1 official - 1.7.21 + 1.8.0 11 1.4.5 UTF-8 From 6a782d3736535d02844ddbff48cba9f230ff209e Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Mon, 2 Jan 2023 11:39:43 +0100 Subject: [PATCH 3/3] Sort simulcasts --- .../controllers/SimulcastController.kt | 12 ++++++--- .../repositories/SimulcastRepository.kt | 25 +++++++++++++------ 2 files changed, 27 insertions(+), 10 deletions(-) diff --git a/src/main/kotlin/fr/ziedelth/controllers/SimulcastController.kt b/src/main/kotlin/fr/ziedelth/controllers/SimulcastController.kt index 3a71116..d005f97 100644 --- a/src/main/kotlin/fr/ziedelth/controllers/SimulcastController.kt +++ b/src/main/kotlin/fr/ziedelth/controllers/SimulcastController.kt @@ -2,6 +2,7 @@ package fr.ziedelth.controllers import fr.ziedelth.entities.Simulcast import fr.ziedelth.repositories.SimulcastRepository +import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* @@ -11,9 +12,14 @@ class SimulcastController(private val simulcastRepository: SimulcastRepository) fun getRoutes(routing: Routing) { routing.route(prefix) { get("/country/{country}") { - val country = call.parameters["country"]!! - println("GET $prefix/country/$country") - call.respond(simulcastRepository.getAll(country)) + try { + val country = call.parameters["country"]!! + println("GET $prefix/country/$country") + call.respond(simulcastRepository.getAll(country)) + } catch (e: Exception) { + e.printStackTrace() + call.respond(HttpStatusCode.InternalServerError, e) + } } } } diff --git a/src/main/kotlin/fr/ziedelth/repositories/SimulcastRepository.kt b/src/main/kotlin/fr/ziedelth/repositories/SimulcastRepository.kt index 51d407c..863dcf4 100644 --- a/src/main/kotlin/fr/ziedelth/repositories/SimulcastRepository.kt +++ b/src/main/kotlin/fr/ziedelth/repositories/SimulcastRepository.kt @@ -1,20 +1,31 @@ package fr.ziedelth.repositories +import fr.ziedelth.entities.Anime +import fr.ziedelth.entities.Country import fr.ziedelth.entities.Simulcast import fr.ziedelth.utils.Database import org.hibernate.Session class SimulcastRepository(session: () -> Session = { Database.getSession() }) : AbstractRepository(session) { fun getAll(tag: String?): List { + val start = System.currentTimeMillis() + val session = getSession.invoke() - val query = session.createQuery( - "SELECT DISTINCT simulcasts FROM Anime WHERE country.tag = :tag", - Simulcast::class.java - ) - query.setParameter("tag", tag) - val list = query.list() + val criteriaBuilder = session.criteriaBuilder + val criteriaQuery = criteriaBuilder.createQuery(Simulcast::class.java) + val root = criteriaQuery.from(Anime::class.java) + criteriaQuery.select(root.get("simulcasts")).distinct(true) + criteriaQuery.where(criteriaBuilder.equal(root.get("country").get("tag"), tag)) + val list = session.createQuery(criteriaQuery).list() session.close() - return list + + // Sort by year and season started by "Winter", "Spring", "Summer", "Autumn" + val seasons = listOf("WINTER", "SPRING", "SUMMER", "AUTUMN") + val sorted = list.sortedWith(compareBy({ it.year }, { seasons.indexOf(it.season) })) + + val end = System.currentTimeMillis() + println("SimulcastRepository.getAll() took ${end - start}ms") + return sorted } fun findBySeasonAndYear(season: String, year: Int): Simulcast? {