From f1b2c3bf5ee4b5b5ca2f2b9d020fbe0e3d8dc6bf Mon Sep 17 00:00:00 2001 From: Ziedelth Date: Fri, 21 Oct 2022 09:29:20 +0200 Subject: [PATCH] Change search method --- src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt b/src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt index 8d52c8e..37839ec 100644 --- a/src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt +++ b/src/main/kotlin/fr/ziedelth/controllers/AnimeController.kt @@ -57,10 +57,10 @@ object AnimeController : IController("/animes") { try { val query = session.createQuery( - "FROM Anime a WHERE a.country.tag = :tag AND LOWER(name) LIKE CONCAT('%', :name, '%') ", +// "FROM Anime a WHERE a.country.tag = :tag AND LOWER(name) LIKE CONCAT('%', :name, '%')", + "SELECT DISTINCT anime FROM Episode e WHERE e.anime.country.tag = :tag AND LOWER(e.anime.name) LIKE CONCAT('%', :name, '%') ORDER BY e.anime.name", Anime::class.java ) - query.maxResults = 10 query.setParameter("tag", country) query.setParameter("name", name.lowercase()) call.respond(query.list() ?: HttpStatusCode.NotFound)